#include<stdio.h> #include<string.h> #include<malloc.h> typedef struct Node{ int x; int y; struct Node* next; }*node,NODE; node add_node(int n){ node rear = (node)malloc(sizeof(NODE)); node front; front= rear; for(int i = 0; i < n; i++){ if(rear != NULL){ rear->next= (node)malloc(sizeof(NODE)); rear = rear->next; if(rear){ int state=scanf("%d %d", &(rear->x), &(rear->y)); rear->next = NULL; } } } if(front != NULL){ node temp = front; front = front->next; free(temp); } return front; } void print_p(node p){ if(p != NULL){ node this_p = p; while(p->next){ p = p->next; this_p->x += p->x; this_p->y += p->y; } printf("%d+%di", this_p->x, this_p->y); } } int main(){ int n = 0; if(scanf("%d", &n)){ node p=add_node(n); print_p(p); } return 0; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:337 |
简单的a+b (C语言代码)浏览:816 |
C语言程序设计教程(第三版)课后习题9.3 (C语言代码)浏览:604 |
IP判断 (C语言代码)浏览:539 |
理财计划 (C语言代码)浏览:467 |
简单的事情 (C语言代码)浏览:638 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:785 |
1392题解(大数相加)浏览:604 |
孤独的骑士 (C语言代码)浏览:1368 |
C语言程序设计教程(第三版)课后习题7.4 (C语言代码)浏览:3242 |