#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 人评分
点我有惊喜!你懂得!浏览:1439 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:1175 |
printf基础练习2 (C语言代码)浏览:648 |
【偶数求和】 (C++代码)浏览:785 |
简单编码 (C++代码)浏览:730 |
WU-蓝桥杯算法提高VIP-勾股数 (C++代码)浏览:1685 |
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)浏览:821 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:651 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:388 |
C语言训练-列出最简真分数序列* (C语言代码)浏览:658 |