解题思路:
注意事项:
参考代码:#include <stdio.h>
#include <stdlib.h>
typedef struct LNode{
int a;
int b;
struct LNode *next;
}LNode,*LinkList;
void CreateList(LinkList &L,int n){
L=(LinkList)malloc(sizeof(LNode));
L->next=NULL;
for (int i=n;i>0;--i){
LNode *p=(LinkList)malloc(sizeof(LNode));
scanf("%d%d",&p->a,&p->b);
p->next=L->next;
L->next=p;
}
}
void AddList(LinkList L,int n,int &a1,int &a2){
LNode *p=L->next;
int j=1;
while (p!=NULL){
a1+=p->a;
a2+=p->b;
p=p->next;
}
}
int main(){
int n;
scanf("%d",&n);
LinkList L;
CreateList(L,n);
int a1=0;
int a2=0;
AddList(L,n,a1,a2);
printf("%d+%di\n",a1,a2);
return 0;
}
0.0分
0 人评分