A+B for input-output
来源:互联网 发布:flox for mac破解版 编辑:程序博客网 时间:2024/06/05 16:55
- 列表内容
Practice (I)
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 <stdio.h>int main(){ int a, b; while( scanf("%d%d",&a,&b) != EOF ) { printf("%d\n", a + b ); } return 0;}
Practice (II)
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<stdio.h>int main(){ int a, b, d, i; while (scanf( "%d", &a) != EOF ) { for (i = 0; i < a; i ++) { scanf( "%d%d", &b, &d ); printf( "%d\n", d+b ); }}}
Practice (III)
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 <stdio.h>#include <stdlib.h>int main(){ int a, b; while( scanf( "%d%d", &a, &b ) != EOF ) { if( a==0 && b==0 ) break; printf( "%d\n", a+b ); } return 0;}
Practice (IV)
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 <stdio.h>#include <stdlib.h>int main (){ int i, n, a, sum; while( scanf( "%d", &n ) !=EOF ) { if( n == 0) break; sum = 0; for( i = 0; i < n; i ++) { scanf( "%d",&a ); sum + = a; } printf( "%d\n" , sum ); } return 0;}
Practice (V)
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<stdio.h>int main(){ int n, a, sum, i, j, k; while ( scanf( "%d" , &n ) != EOF ) { for ( i = 0; i < n; i ++ ) { scanf( "%d" , &k ); sum = 0; for( j = 0; j < k; j ++) { scanf( "%d" , &a ); sum + = a; } printf( "%d\n" , sum ); } } return 0;}
Practice (VI)
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<stdio.h>int main (){ int n, a, sum, i, j, k; while ( scanf( "%d" , &k ) != EOF) { sum = 0; for( j = 0; j < k; j ++) { scanf( "%d" , &a ); sum + = a; } printf( "%d\n" , sum ); } return 0;}
Practice (VII)
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 <stdio.h>int main (){ int a, b, sum; while( scanf( "%d%d" , &a, &b) != EOF ) { sum = a + b; printf( "%d\n" , sum ); printf( "\n" , sum ); } return 0;}
Practice (VIII)
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<stdio.h>int main(){ int n, a, sum, i, j, k; while ( scanf( "%d" , &n ) != EOF) { for (i = 0; i < n; i ++) { scanf( "%d" , &k ); sum=0; for( j = 0; j < k; j ++) { scanf( "%d" , &a ); sum+=a; } printf("%d\n",sum); if(i!=n-1) printf("\n"); } } return 0;}
- A+B for input-output
- A+B for Input-Output Practice (I)
- A+B for Input-Output Practice (II)
- A+B for Input-Output Practice (III)
- A+B for Input-Output Practice (IV)
- A+B for Input-Output Practice (V)
- A+B for Input-Output Practice (VI)
- A+B for Input-Output Practice (VII)
- A+B for Input-Output Practice (VIII)
- A+B for Input-Output Practice (VIII)
- A+B for Input-Output Practice (I)
- A+B for Input-Output Practice (II)
- A+B for Input-Output Practice (III)
- A+B for Input-Output Practice (IV)
- A+B for Input-Output Practice (V)
- A+B for Input-Output Practice (VI)
- A+B for Input-Output Practice (VII)
- A+B for Input-Output Practice (VIII)
- Win下操作系统快捷开发环境的搭建补充视频
- 二分搜索(1)
- PKU 2017 信科/软微 夏令营部分机试题解
- fork()请问下面的程序一共输出多少个“-”?
- 设一个没有头结点指针的单链表。一个指针指向此单链表中间的一个结点(不是第一个,也不是最后一个结点),将该结点从单链表中删除,要求时间复杂度O(1)。
- A+B for input-output
- 深入分析JavaWeb Item31 -- JDBC(MySQL)事务管理
- java中overload和override区别
- 泛型
- Chpater03 Hadoop组件(三) Hadoop读写
- bottle的gunicorn+gevent部署 和 gunicorn+meinheld 部署
- 自己实现一个二叉查找树BinarySearchTree
- Span使用之利用系统Span样式实现模糊搜索,匹配变色的特殊UI效果
- hdu2266——How Many Equations Can You Find