解题思路:
注意事项:
参考代码:
#include <stdio.h>
#include <malloc.h>
typedef struct linklist
{
int real,image;
struct linklist *next;
}ComplexList;
ComplexList *CreateList()
{
ComplexList *head,*p,*q;
head=(ComplexList*)malloc(sizeof(ComplexList));
head->next=NULL;
q=head;
int n=10;
while(n--)
{
p=(ComplexList*)malloc(sizeof(ComplexList));
scanf("%d%d",&p->real,&p->image);
q->next=p;
q=p;
}
q->next=NULL;
return head;
}
void CountList(ComplexList *head)
{
int sum1=0,sum2=0;
ComplexList *p=head;
p=p->next;
while(p!=NULL)
{
sum1+=p->real;
sum2+=p->image;
p=p->next;
}
printf("%d+%di\n",sum1,sum2);
}
int main()
{
ComplexList *head=CreateList();
CountList(head);
return 0;
}
0.0分
2 人评分
C二级辅导-计负均正 (C语言代码)浏览:1202 |
计算质因子 (C++代码)100以内质数直接打表就好了浏览:1193 |
C语言训练-数字母 (C语言代码)浏览:585 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:422 |
【密码】 (C语言代码)浏览:333 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:768 |
上车人数 (C语言代码)浏览:781 |
打水问题 (C语言代码)浏览:1072 |
用筛法求之N内的素数。 (C语言代码)浏览:1262 |
C语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:770 |