D天天的简单加法
D天天的简单加法
Time Limit:1000MS  Memory Limit:65536K
Total Submit:367 Accepted:163
Description
给定两个整数序列,每个序列N个整数,将两个序列中对应位置的数相加,得到一个"和序列"。已知序列长度不超过100。
Input
输入第一行是一个正整数N(N<=100)。 
接下来两行,每行输入N个整数,代表一个序列。
Output
输出对应的"和序列",输出占一行,每个元素之间用一个空格分开,最后一个元素后面没有空格。
Sample Input
5
1 2 3 4 5
2 2 2 2 2Sample Output
3 4 5 6 7
代码:
#include<stdio.h>
int main()
{
	int i,N;
	int a[101]={0},b[101]={0},c[101]={0};
	while(scanf("%d",&N)!=EOF)
	{
		for(i=0;i<N;i++)
		{
			scanf("%d",&a[i]);
		}
		for(i=0;i<N;i++)
		{
			scanf("%d",&b[i]);
			c[i]=a[i]+b[i];
		}
		for(i=0;i<N;i++)
		{
			if(i==N-1)    //控制空格输出
			        printf("%d\n",c[i]);
			else
			        printf("%d ",c[i]);
		}
	}
}
评论
