http://acm.hdu.edu.cn/showproblem.php?pid=1089

Problem Description
Your task is to Calculate a + b.
Too easy?! Of course! I specially designed the problem for acm beginners. 
You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim. 
 
Input
The input will consist of a series of pairs of integers a and b, 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 5
10 20
 
Sample Output
6 30
 
代码:

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

  

http://acm.hdu.edu.cn/showproblem.php?pid=1090

Problem Description
Your task is to Calculate a + b.
 
Input
Input contains an integer N in the first line, and then N lines follow. Each line consists of a pair of integers a and b, 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
2 1 5 10 20
 
Sample Output
6
30
 
代码:

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int T;
  8. cin >> T;
  9. int sum=0;
  10. for(int i = 1;i <= T;i ++)
  11. {
  12. int a,b;
  13. cin>>a>>b;
  14. sum=a+b;
  15. cout<<sum<<endl;
  16. }
  17. return 0;
  18. }

  

http://acm.hdu.edu.cn/showproblem.php?pid=1091

Problem Description
Your task is to Calculate a + b.
 
Input
Input contains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line. A test case containing 0 0 terminates the input and this test case is not to 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
0 0
 
Sample Output
6
30
 
代码:

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

  

http://acm.hdu.edu.cn/showproblem.php?pid=1092

Problem Description
Your task is to Calculate the sum of some integers.
 
Input
Input contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed.
 
Output
For each group of input integers you should output their sum in one line, and with one line of output for each line in input. 
 
Sample Input
4 1 2 3 4
5 1 2 3 4 5
0
 
Sample Output
10
15
 
代码:

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n;
  8. while(cin>>n)
  9. {
  10. if(n==0)
  11. break;
  12. int sum=0;
  13. for(int i=1; i<=n; i++)
  14. {
  15. int x;
  16. cin>>x;
  17. sum+=x;
  18. }
  19. cout<<sum<<endl;
  20. }
  21. return 0;
  22. }

  

http://acm.hdu.edu.cn/showproblem.php?pid=1093

Problem Description
Your task is to calculate the sum of some integers.
 
Input
Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line. 
 
Output
For each group of input integers you should output their sum in one line, and with one line of output for each line in input. 
 
Sample Input
2
4 1 2 3 4
5 1 2 3 4 5
 
Sample Output
10
15
 
代码:

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int N,M;
  8. cin >> N;
  9.  
  10. for(int i=1;i<=N;i++)
  11. {
  12. int sum=0;
  13. cin>>M;
  14. for(int j=1;j<=M;j++)
  15. {
  16. int x;
  17. cin>>x;
  18. sum+=x;
  19. }
  20. cout<<sum<<endl;
  21. }
  22. return 0;
  23. }

  

http://acm.hdu.edu.cn/showproblem.php?pid=1094

Problem Description
Your task is to calculate the sum of some integers.
 
Input
Input contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line. 
 
Output
For each test case you should output the sum of N integers in one line, and with one line of output for each line in input. 
 
Sample Input
4 1 2 3 4
5 1 2 3 4 5
 
Sample Output
10
15
 
代码:

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int N;
  8. while(scanf("%d",&N)!=EOF)
  9. {
  10. int sum=0;
  11. for(int i=1;i<=N;i++)
  12. {
  13. int x;
  14. cin>>x;
  15. sum+=x;
  16. }
  17. cout<<sum<<endl;
  18. }
  19. return 0;
  20. }

  

http://acm.hdu.edu.cn/showproblem.php?pid=1095

Problem Description
Your task is to Calculate a + b.
 
Input
The input will consist of a series of pairs of integers a and b, 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, and followed by a blank line. 
 
Sample Input
1 5
10 20
 
Sample Output
6

30

 
代码:

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int a,b;
  8. int sum=0;
  9. while(cin>>a>>b)
  10. {
  11. sum=a+b;
  12. cout<<sum<<endl<<endl;
  13. }
  14. return 0;
  15. }

http://acm.hdu.edu.cn/showproblem.php?pid=1096

Problem Description
Your task is to calculate the sum of some integers.
 
Input
Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line. 
 
Output
For each group of input integers you should output their sum in one line, and you must note that there is a blank line between outputs.
 
Sample Input
3
4 1 2 3 4
5 1 2 3 4 5
3 1 2 3
 
Sample Output
10

15

6

 
代码:

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int N,M;
  8. cin>>N;
  9. for(int i=1;i<=N;i++)
  10. {
  11. int sum=0;
  12. cin>>M;
  13. for(int j=1;j<=M;j++)
  14. {
  15. int x;
  16. cin>>x;
  17. sum+=x;
  18. }
  19. if(N!=i)
  20. cout<<sum<<endl<<endl;
  21. else
  22. cout<<sum<<endl;
  23. }
  24. return 0;
  25. }

  

HDU 1089 到1096 a+b的输入输出练习的更多相关文章

  1. C++ 的简单输出输入 HDU 1089~1096

    A+B for Input-Output Practice (I) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...

  2. HDU 1089 A+B for Input-Output Practice (I)

    #include <cstdio> int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF) prin ...

  3. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

  4. 小C的故事(快速学C语言,,,极速版!)

    前几天这篇博客写了太多废话! 删啦~~. 本篇博客只是为chd A协的全嫩小鲜肉入门C语言的预科, 如果你在此处学习C语言, 不幸走火入魔, 小弱概不负责. //请直接随便找个C语言编译器,抄一下下面 ...

  5. 网络爬虫 - 真·AC自动机

    前几天无聊,忽然想写点有趣的代码,关于网络方面的,刚开始就想写一个能从oj上自动拉个比赛的软件,后来查资料时看到了神奇的AC自动机,于是自己也去实现了遍. 一天狂A 500多道...就当自娱自乐了.在 ...

  6. 2道acm编程题(2014):1.编写一个浏览器输入输出(hdu acm1088);2.encoding(hdu1020)

    //1088(参考博客:http://blog.csdn.net/libin56842/article/details/8950688)//1.编写一个浏览器输入输出(hdu acm1088)://思 ...

  7. HDU 2993 MAX Average Problem(斜率DP经典+输入输出外挂)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2993 题目大意:给出n,k,给定一个长度为n的序列,从其中找连续的长度大于等于k的子序列使得子序列中的 ...

  8. hdu(杭电oj)输入输出练习题目总结

    1000.1001 .1089.1090.1091.1092.1093.1094.1095.1096

  9. hdu 1426(DFS+坑爹的输入输出)

    Sudoku Killer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

随机推荐

  1. DBUtils温习1

    1.简介 Commons DBUtIls是Apache组织提供的一个开源JDBC工具类库,它是对JDBC的简单封装,学习成本极低,但是使用DBUtils却极大的简化了dao层的开发,少些了很多的jdb ...

  2. python 类与类之间的关系

    一.依赖关系(紧密程度最低) (1)简单的定义:就是方法中传递一个对象.此时类与类之间存在依赖关系,此关系比较低. (2)实例植物大战僵尸简易版 题目要求:创建一个植物,创建一个僵尸 1.植物:名字. ...

  3. 【Linux基础】history查看历史命令

    1.history命令 “history”命令就是历史记录.它显示了在终端中所执行过的所有命令的历史. history //显示终端执行过的命令 history //显示最近10条终端执行过的命令 C ...

  4. python六十六课——单元测试(二)

    ''' 封装Person类 ''' class Person: def __init__(self,name,age): self.name=name self.age=age def getAge( ...

  5. I/O 机制的介绍(Linux 中直接 I/O 机制的介绍)

    IO连接的建立方式 1.缓存IO.流式IO: 2.映射IO.块式IO: 3.直接IO. IO的方式: 同步.异步.定时刷新: MMAP与内核空间 mmap使用共享用户空间与内核空间实现: 直接 I/O ...

  6. 转://使用insert插入大量数据的总结

    使用insert插入大量数据的个人经验总结在很多时候,我们会需要对一个表进行插入大量的数据,并且希望在尽可能短的时间内完成该工作,这里,和大家分享下我平时在做大量数据insert的一些经验. 前提:在 ...

  7. maven tomcat jstl 异常

    在跑一个带jstl的例子的时候,遇到了这样一个错误: org.springframework.web.util.NestedServletException: Handler processing f ...

  8. WiFi-ESP8266入门http(1)-建立服务器,直接发送网

    #include <ESP8266WiFi.h> /*** 该工程可以在2.4.0版本esp8266库中运行,没在更高版本库中进行测试 ***/ const char *ssid = &q ...

  9. 转载 (三)surging 微服务框架使用系列之我的第一个服务(审计日志)

    (三)surging 微服务框架使用系列之我的第一个服务(审计日志)   前言:前面准备了那么久的准备工作,现在终于可以开始构建我们自己的服务了.这篇博客就让我们一起构建自己的第一个服务---审计日志 ...

  10. Linux内核入门到放弃-进程管理和调度-《深入Linux内核架构》笔记

    进程优先级 硬实时进程 软实时进程 普通进程 O(1)调度.完全公平调度器 抢占式多任务处理(preemptive multitasking):各个进程都分配到一定的时间段可以执行.时间段到期后,内核 ...