1137: 零起点学算法44——多组测试数据输出II

谁践踏了优雅 2023-01-10 13:25 293阅读 0赞

Description

对于每一组数据输入后先处理然后输出结果,再输入第2组数据,
输出数据之间要求有一个空行

  1. int main()
  2. {
  3. int a,b,c,t=0;
  4. while(scanf("%d%d",&a,&b)!=EOF)
  5. {
  6. c=a+b;
  7. if( t>0) printf("\n");
  8. printf("%d\n",c);//注意后面的\n
  9. t++;
  10. }
  11. }

Input

多组测试数据,每组输入3个整数

Output

对于每组测试数据,输出1行,内容为输入的3个数的和,每2组测试数据之间有1个空行

" class="reference-link">Sample Input 5f8f312f51791b8bb0ed0ae07c2ffa43.gif

  1. 1 2 3
  2. 4 5 6

Sample Output

  1. 6
  2. 15

Source

零起点学算法

Code

  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<iomanip>
  4. #include<math.h>
  5. using namespace std;
  6. int main()
  7. {
  8. int a,b,c;
  9. while(~scanf("%d%d%d",&a,&b,&c))
  10. {
  11. cout<<a+b+c<<endl;
  12. cout<<endl;
  13. }
  14. }

发表评论

表情:
评论列表 (有 0 条评论,293人围观)

还没有评论,来说两句吧...

相关阅读