1137: 零起点学算法44——多组测试数据输出II
Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 1513 Accepted: 1007
[ Submit ][ Status ][ Web Board ]
Description
对于每一组数据输入后先处理然后输出结果,再输入第2组数据,
输出数据之间要求有一个空行
int main()
{
int a,b,c,t=0;
while(scanf("%d%d",&a,&b)!=EOF)
{
c=a+b;
if( t>0) printf("\n");
printf("%d\n",c);//注意后面的\n
t++;
}
}
Input
多组测试数据,每组输入3个整数
Output
对于每组测试数据,输出1行,内容为输入的3个数的和,每2组测试数据之间有1个空行
Sample Input
1 2 3 4 5 6
Sample Output
6 15
Source
零起点学算法
1 #include<stdio.h> 2 int main(){ 3 int a,b,c,t= 0 ; 4 while (scanf( " %d%d%d " ,&a,&b,&c)!= EOF){ 5 if (t> 0 ) printf( " \n " ); 6 printf( " %d\n " ,a+b+ c); 7 t++ ; 8 } 9 return 0 ; 10 }
//别小看这题简单。 记住 最后一组数据后面只有一个换行 没有两个, 所以应当是先if判断再输出,而不是先输出后判断。 虽然最后结果一样,但是最后的换行不一样!!!
查看更多关于1137: 零起点学算法44——多组测试数据输出II的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did238283