acm.hit.edu.cn
1001
A+B
for each pair of integers A and B ( 0 <= A,B <= 10) , Output the result of A+B on a single line. Sample Input
1 2 3 4Sample Output
3 7Sample Code
#include <stdio.h> int main(void) { int a, b; while (scanf("%d %d", &a, &b)==2) printf("%d\n",a+b); return 0; }
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;
int main()
{
int a,b;
while(scanf("%d%d",&a,&b) == 2)
{
printf("%d\n",a+b);
}
return 0;
}
1002
A+B+C
For each pair of integers A B and C ( -2^31 <= A, B, C<= 2^31-1 ), Output the result of A+B+C on a single line. Sample Input
1 2 3 3 4 3Sample Output
6 10提示 请注意32位机上int的表示范围。
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;
int main()
{
long long int a, b, c;
while(scanf("%lld %lld %lld",&a,&b,&c) == 3)
{
printf("%lld\n",a+b+c);
}
return 0;
}