孤鸿悬影


私信TA

用户名:Nonewilli

访问量:8114

签 名:

人生尝尝叹叹几十年,风风雨雨又多少岁月。

等  级
排  名 323
经  验 5314
参赛次数 0
文章发表 59
年  龄 0
在职情况 学生
学  校 中国石油大学
专  业 自动化

  自我简介:

了却天涯独此命,乘舟散尽也由荣。

解题思路:

注意事项:

参考代码:

#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#define I sizeof(struct a)
struct a{
	int s;
	int x;
	struct a *next;
};
int main(){
	struct a *head,*a1,*a2;
	int n,m,i,sum1=0,sum2=0;
	scanf("%d",&n);
	head=(struct a *)malloc(I);
	head->next=NULL;
	a2=head;
	for(m=0;m<n;m++){
		a1=(struct a *)malloc(I);
		scanf("%d",&a1->s);
		scanf("%d",&a1->x);
		a2->next=a1;
		a2=a1;
	}
	a2->next=NULL;
	for(i=0;i<n;i++){
		head=head->next;
		sum1=head->s+sum1;
		sum2=head->x+sum2;
	}
	printf("%d+%di",sum1,sum2);
}


 

0.0分

1 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区