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+空格+'要输出的内容',一定要是英文状态下 ...
随机推荐
- angular 常用插件集合
md5加密 https://www.npmjs.com/package/md5-typescript angular echarts https://github.com/xieziyu/ng ...
- 六招让你的Ubuntu马上提速
Chris Hoffman Ubuntu的启动速度非常快,按了开机键之后很快就进入桌面.但我们仍然可以充分利用内存,通过多种方法让开机速度更快.某些方法真的可以提速,对于旧电脑的效果尤其明显. 选用轻 ...
- linux下uptime命令详解
uptime uptime 另外还有一个参数 -V(大写),是用来查询版本的 procps是一个实用程序包,主要包括ps top kill等程序主要用来显示与控制一些系统信息,进程状态之类的内容. 以 ...
- POJ 2243 Knight Moves(BFS)
POJ 2243 Knight Moves A friend of you is doing research on the Traveling Knight Problem (TKP) where ...
- GitHub下的文件放到Linux系统下
1.在GitHub账号下clone URL 项目. 2.到Linux服务器下执行以下操作: (1) mkdir test (2) cd test/ (3) git clone 复制的项目URL
- shlve 模块
shlve 模块 也用于序列化 它与pickle 不同之处在于 不需要惯性文件模式什么的 直接把它当成一个字典来看待 它可以直接对数据进行修改 而不用覆盖原来的数据 而pickle 你想要修改只能 ...
- linux图形和命令界面切换
一.系统不在虚拟机中的情况 使用ctrl+alt+F1~6切换到命令行界面:ctrl+alt+F7切换到图形界面 二.系统在虚拟机中的情况 Ctrl+Alt+shift+F1~6切换到命令行界面:使用 ...
- java 实现简单的顺序队列
package com.my; import java.util.Arrays; /** * 顺序队列 * @author wanjn * */ public class ArrayQueue { p ...
- maven包上传私服
选择需要上传的项目右键-->Run As-->Run Configurations-->Maven Buid-->右键 new -->选择 base directory- ...
- XGboost学习总结
XGboost,全称Extrem Gradient boost,极度梯度提升,是陈天奇大牛在GBDT等传统Boosting算法的基础上重新优化形成的,是Kaggle竞赛的必杀神器. XGboost属于 ...