CSU 1000/1001/1002 A+B问题

举报
用户已注销 发表于 2021/11/19 05:46:38 2021/11/19
【摘要】 1000: Description Your task is to Calculate a + b. Input Input contains multiple test cases. Each test case consists of a pair of integers a and b(0<=...

1000:

Description

Your task is to Calculate a + b.

Input

Input contains multiple test cases. Each test case consists of a pair of integers a and b0<=a,b<=20, separated by a space, one pair of integers per line.

Output

For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.

Sample Input

1 1

Sample Output

2

代码:


  
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. inta, b;
  6. while(cin >> a >> b)
  7. {
  8. cout << a + b << endl;
  9. }
  10. return 0;
  11. }


1001:

Description

Your task is to Calculate a + b.

Input

There are multiple test cases. Each test case contains only one line. Each line consists of a pair of real number a and b(0<=a,b<=1000000), separated by a space.

Output

For each case, output the answer in one line rounded to 4 digits after the decimal point.

Sample Input

1 510 200.1 1.5

Sample Output

6.000030.00001.6000

代码:

   
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. double a, b;
  6. while(cin >> a >> b)
  7. {
  8. printf("%.4f",a+b);
  9. cout << endl;
  10. }
  11. return 0;
  12. }


1002:

Description

Your task is to Calculate a + b.

Input

There are multiple test cases. Each test case contains only one line. Each line consists of a pair of integers a and b1=< a,b <=1016, separated by a space. Input is followed by a single line with a = 0, b = 0, which should not be processed.

Output

For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.

Sample Input

1 5
10 20
10000000000000000 10000000000000000
0 0

Sample Output

6
30
20000000000000000

代码:


  
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. long long a, b;
  6. while(cin >> a >> b)
  7. {
  8. if(a == 0 && b == 0)break;
  9. cout << a + b<<endl;
  10. }
  11. return 0;
  12. }

文章来源: blog.csdn.net,作者:csuzhucong,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/nameofcsdn/article/details/52043151

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。