你好


私信TA

用户名:dotcpp0646549

访问量:474

签 名:

等  级
排  名 2359
经  验 2267
参赛次数 0
文章发表 22
年  龄 0
在职情况 学生
学  校 傻逼大学,啥都不行,就会青年大学习
专  业 大数据

  自我简介:

#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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区