武汉科技大学ACM :1002: A+B for Input-Output Practice (II)
2014-12-05 20:23
441 查看
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> #include<string> using namespace std; int main() { int n,a,b; int sum; string result; char s[100]; cin>>n; for(int i=0;i<n;i++) { cin>>a; cin>>b; sum = a+b; sprintf(s, "%d",sum);//将整数转为字符串型 result += s; result += "\n"; } cout<<result; return 1; }
相关文章推荐
- 1002: A+B for Input-Output Practice (II)
- 武汉科技大学ACM :1001: A+B for Input-Output Practice (I)
- 武汉科技大学ACM :1003: A+B for Input-Output Practice (III)
- 武汉科技大学ACM :1004: A+B for Input-Output Practice (IV)
- 武汉科技大学ACM :1005: A+B for Input-Output Practice (V)
- ACM----1086 A+B for Input-Output Practice (II)
- 武汉科技大学ACM :1006: A+B for Input-Output Practice (VI)
- 山东理工 ACM [1011] A+B for Input-Output Practice (II)
- 「HD_ACM」 A+B for Input-Output Practice (II)
- 武汉科技大学ACM :1007: A+B for Input-Output Practice (VII)
- 武汉科技大学ACM :1008: A+B for Input-Output Practice (VIII)
- 杭电ACM 1090 A+B for Input-Output Practice (II)
- 杭电ACM 1090 (A+B for Input-Output Practice (II))
- 杭电 ACM 1090:A+B for Input-Output Practice (II)
- HDU_ACM_A+B for Input-Output Practice (II)
- ACM STEP 1.1.2 A+B for Input-Output Practice (II)
- 「HD_ACM」A+B for Input-Output Practice (IV)
- HDU A+B for Input-Output Practice (II)
- HDU水题1090 ( A+B for Input-Output Practice (II) )
- 杭电ACM 1095 A+B for Input-Output Practice (VII)