C++ 的简单输出输入 HDU 1089~1096
A+B for Input-Output Practice (I)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 129829 Accepted Submission(s): 69922
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;
while (cin >> a>>b){
cout <<a+b<<endl;
}
return 0;
}
A+B for Input-Output Practice (II)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 97559 Accepted Submission(s): 62308
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 n;
cin >>n;
while (n--){
int a,b;
cin >>a >>b;
cout <<a+b<<endl;
}
return 0;
}
A+B for Input-Output Practice (III)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 108194 Accepted Submission(s): 56933
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;
while (cin>>a>>b,a||b){
cout<<a+b<<endl;
}
return 0;
}
A+B for Input-Output Practice (IV)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 99949 Accepted Submission(s): 52783
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,n){
int sum=0,num;
while (n--){
cin>>num;
sum+=num;
}
cout << sum <<endl;
}
return 0;
}
A+B for Input-Output Practice (V)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 74170 Accepted Submission(s): 49454
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 <iostream>
using namespace std;
int main (){
int n;
while (cin>>n,n){
int sum=0,num;
while (n--){
cin>>num;
sum+=num;
}
cout << sum <<endl;
}
return 0;
}
A+B for Input-Output Practice (VI)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 69477 Accepted Submission(s): 46476
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 <iostream>
using namespace std;
int main (){
int n,num;
while (cin >> n){
int sum = 0;
for (int i = 1;i <= n;i ++){
cin >> num;
sum += num;
}
cout << sum << endl;
}
return 0;
}
A+B for Input-Output Practice (VII)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 68666 Accepted Submission(s): 45664
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 <iostream>
using namespace std;
int main (){
int a,b;
while (cin >> a >> b){
cout << a+b << endl << endl;
}
return 0;
}
A+B for Input-Output Practice (VIII)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 149649 Accepted Submission(s): 45273
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 <iostream>
using namespace std;
int main (){
int n;
cin >> n;
while (n--){
int t,sum = 0,num;
cin >> t;
for (int i = 1;i <= t;i++){
cin >> num;
sum += num;
}
cout << sum << endl;
if (n) cout<< endl ;
}
return 0;
}
C++ 的简单输出输入 HDU 1089~1096的更多相关文章
- 【VB超简单入门】五、基本输出输入
之前讲了VB IDE的基本操作和概念,接下来要开始将VB语言的编程了. 程序最重要的部分是输出和输入,输入数据,经过计算机处理,再输出结果.本文将介绍两种最基本的输出输入方法,分别是Print.Msg ...
- 1102: 零起点学算法09——继续练习简单的输入和计算(a-b)
1102: 零起点学算法09--继续练习简单的输入和计算(a-b) Time Limit: 1 Sec Memory Limit: 520 MB 64bit IO Format: %lldSub ...
- 1101: 零起点学算法08——简单的输入和计算(a+b)
1101: 零起点学算法08--简单的输入和计算(a+b) Time Limit: 1 Sec Memory Limit: 128 MB 64bit IO Format: %lldSubmitt ...
- java入门---简介&简单输出小例子&开发前准备
Java是由Sun Microsystems公司于1995年5月推出的Java面向对象程序设计语言和Java平台的总称.由James Gosling和同事们共同研发,并在1995年正式推出.J ...
- Java基础(5)- 输出输入
输出输入 public class Input { public static void main (String[] args){ try { /** * 打开文件流进行读取 */ Scanner ...
- c++学习笔记---05--- C++输出输入小结
C++输出输入小结 题目: 这个程序将向用户提出一个"Y/N"问题,然后把用户输入的值赋值给answer变量. 要求: 针对用户输入'Y'或'y'和'N'或'n'进行过滤: 发掘程 ...
- C#实现并口输出输入高低电位
PC并行口各阵脚定义: 1.选通,PC->Printer 2-9 数据(D0-D7) 10.应答(ACK),Printer->PC 11.忙(BUSY),Printer->PC 12 ...
- HDU 1089 到1096 a+b的输入输出练习
http://acm.hdu.edu.cn/showproblem.php?pid=1089 Problem Description Your task is to Calculate a + b.T ...
- python简单的输入与输出
1 首先利用python完成简单的输出,运行如下: python和c语言类似,但又有所不同,python开发快,语言简洁,我是这样对比学的 输出:print+空格+'要输出的内容',一定要是英文状态下 ...
随机推荐
- 在引用的laravel的@include子模板中传递参数
调用传参: @include("message",['msg'=>'中国']) 在message子模板中调用msg的值: {{msg}}
- html页面标题增加图标方法
有些网站的网页标题部分有图标,很带感.方法很简单: 在<head></head>部分增加下列一行代码即可. <link rel="shortcut icon&q ...
- word个人信息的一种处理方式
下面是一种解决office文件更改作者的方法,步骤如下: 第一步:进入Word,Excel,或PowerPoint, 随便打开一个文件: 第二步:点击左上角的文件,进入文件功能界面: 第三步:点击选项 ...
- java动手动脑2
仔细阅读示例: EnumTest.java,运行它,分析运行结果? 你能得到什么结论?你掌握了枚举类型的基本用法了吗? 运行结果: 第一个false是判断s和t是否引用同一个对象,第二个false是判 ...
- 安装ubuntu gnome桌面
注意: ubuntu 14.04.5默认的为unity桌面,有多点触发,没有自带Tweak Tool工具. 安装gnome桌面 sudo apt-get install ubuntu-gnome-de ...
- angular2的模板语法
Angular 应用管理着用户之所见和所为,并通过 Component 类的实例(组件)和面向用户的模板来与用户交互. 从使用模型-视图-控制器 (MVC) 或模型-视图-视图模型 (MVVM) 的经 ...
- tf 版本更新 记录
tf 经常更新版本,网上教程又是各版本都有,且不标明版本,致使各种用法难以分清哪个新,哪个旧,这里做个记录,以前的博客我就不更新了,请大家见谅. tf.nn.rnn_cell 改为 tf.contri ...
- jquery 正则表达式
- background低版本安卓浏览器不支持复合属性,要分开写
background:url("http://..../xxx.jpg") no-repeat center/cover; 这种复合形式在有些低端安卓浏览器中不支持,最好分开写: ...
- java基础学习之抽象类
以下内容是自己学习后的一个备忘笔记,理解上肯定有很多问题,望有耐心的大神能给予指点,谢谢 定义:抽象是对事物的一个模糊定义,它主要对那些有共性功能但具体实现不同的对象进行抽象,提高代码的复用性和简洁性 ...