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
 
代码:

#include <iostream>

using namespace std;

int main()
{
int a,b;
int sum=0;
while(cin>>a>>b)
{
sum=a+b;
cout<<sum<<endl;
}
return 0;
}

  

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
 
代码:

#include <iostream>

using namespace std;

int main()
{
int T;
cin >> T;
int sum=0;
for(int i = 1;i <= T;i ++)
{
int a,b;
cin>>a>>b;
sum=a+b;
cout<<sum<<endl;
}
return 0;
}

  

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
 
代码:

#include <iostream>

using namespace std;

int main()
{
int a,b;
int sum = 0;
while(cin >> a >> b)
{
if(a == 0 && b == 0)
break;
else
sum = a + b;
cout << sum << endl;
}
return 0;
}

  

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
 
代码:

#include <iostream>

using namespace std;

int main()
{
int n;
while(cin>>n)
{
if(n==0)
break;
int sum=0;
for(int i=1; i<=n; i++)
{
int x;
cin>>x;
sum+=x;
}
cout<<sum<<endl;
}
return 0;
}

  

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
 
代码:

#include <bits/stdc++.h>

using namespace std;

int main()
{
int N,M;
cin >> N; for(int i=1;i<=N;i++)
{
int sum=0;
cin>>M;
for(int j=1;j<=M;j++)
{
int x;
cin>>x;
sum+=x;
}
cout<<sum<<endl;
}
return 0;
}

  

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
 
代码:

#include <bits/stdc++.h>

using namespace std;

int main()
{
int N;
while(scanf("%d",&N)!=EOF)
{
int sum=0;
for(int i=1;i<=N;i++)
{
int x;
cin>>x;
sum+=x;
}
cout<<sum<<endl;
}
return 0;
}

  

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

 
代码:

#include <bits/stdc++.h>

using namespace std;

int main()
{
int a,b;
int sum=0;
while(cin>>a>>b)
{
sum=a+b;
cout<<sum<<endl<<endl;
}
return 0;
}

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

 
代码:

#include <bits/stdc++.h>

using namespace std;

int main()
{
int N,M;
cin>>N;
for(int i=1;i<=N;i++)
{
int sum=0;
cin>>M;
for(int j=1;j<=M;j++)
{
int x;
cin>>x;
sum+=x;
}
if(N!=i)
cout<<sum<<endl<<endl;
else
cout<<sum<<endl;
}
return 0;
}

  

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. Myeclipse2017C版本破解

    原文地址: https://blog.csdn.net/qq_33945246/article/details/79589152

  2. LDAP概念

    1.1.LDAP目录结构   此图为树形目录结构,我将此跳过去了,因为这个是按照“国家这种结构来划分的”.如果你喜欢这样看更好,如下还有一种: 树也可以根据互联网域名组主.这种命名方式正越来越受欢迎, ...

  3. mabatis insert into on duplicate key

    一.mabatis实现saveOrUpdate功能 <insert id="insert" parameterType="hystrixconfigdo" ...

  4. Oracle会话超时退出设置

    前一段时间客户打电话说自从数据库搬迁后连接数据库总是提示会话不可用,和客户沟通才知到他们连接数据库的程序是从早上连上数据库后就一直保持连接状态,一天中需要执行几次操作,由于数据库中的会话连接有超时限制 ...

  5. 005_python对整数的拼接

    一. (1)需要把整数组成的列表或整数字符串混合的列表拼接成字符串,实现如下: arr=[1,2,3,4,"5"] print ','.join(map(str,arr)) pri ...

  6. 8.oop-多态

    一.继承1.定义:子类继承父类,会继承父类的属性和方法2.语法:extends关键字 子类 extends 父类3.特点:java中的继承是单一继承,子类只能继承一个父类,但是父类可以有多个子类4.用 ...

  7. ORA-27154: post/wait create failed ORA-27300 ORA-27301 ORA-27302

    今天刚装了Oracle 11g,配制好了之后启动数据库时遇到下面的错误:SQL> startupORA-27154: post/wait create failedORA-27300: OS s ...

  8. CentOS自带定时任务crontab

    设置定时任务规则,crontab -e,如下示例为每一分钟执行一次脚本 在脚本中写入内容时需注意路径,可以写绝对路径,也可以按照如下形式 exepath=$(cd "$(dirname &q ...

  9. netty简单样例

    package com.example.demohystrix.process; import io.netty.bootstrap.ServerBootstrap; import io.netty. ...

  10. 几种content-type提交以及$_POST 和php://input

    在表单提交数据时,需要告诉服务端自己的content-type,好让服务端处理. 默认表单提交是x-www-form-urlencoded,还有一种常见的 multipart/form-data.那这 ...