#include<stdio.h> #include<stdlib.h> typedef struct elemtype { int a; int b; struct elemtype *next; } elemtype; void xf(elemtype *L) { elemtype *ch = (elemtype *)malloc(sizeof(elemtype)); scanf("%d%d", &ch->a, &ch->b); ch->next = NULL; while (L->next != NULL) { L = L->next; } L->next = ch; } void xf1(elemtype *L) { int a = 0, b = 0; elemtype *ch = L->next; while (ch != NULL) { a += ch->a; b += ch->b; ch = ch->next; } printf("%d+%di", a, b); } int main() { elemtype *L; L = (elemtype *)malloc(sizeof(elemtype)); L->next = NULL; int a; scanf("%d", &a); for (int i = 0; i < a; i++) { xf(L); } xf1(L); elemtype *tem; while(L!=NULL){ tem = L; L=L->next; free(tem); } return 0; }
0.0分
0 人评分
【回文数(二)】 (C语言代码)浏览:855 |
汽水瓶 (C语言代码)浏览:704 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:802 |
数组输出 (C语言代码)--此题的题目描述有问题浏览:1817 |
计算质因子 (C++代码)浏览:1644 |
简单的a+b (C语言代码)浏览:631 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:648 |
【计算两点间的距离】 (C语言代码)浏览:1494 |
1157题解浏览:716 |
C语言程序设计教程(第三版)课后习题10.5 (C语言代码)浏览:546 |