武汉科技大学ACM :1001: A + B Problem
Problem Description
Calculate A + B.
Input
Each line will contain two integers A and B. Process to end of file.
Output
For each case, output A + B in one line.
Sample Input
1 1 2 2 3 3
Sample Output
2 4 6
我的代码:
1 #include <stdio.h> 2 int main() 3 { 4 int A,B,sum; 5 while(scanf("%d%d",&A,&B) != EOF) 6 7 { 8 sum=A+B; 9 printf("%d\n",sum); 10 } 11 return 0; 12 }
其他代码:
1 #include<stdio.h> 2 int main() 3 { 4 int a, b; 5 scanf("%d%d", &a, &b); 6 printf("%d\n",a + b); 7 scanf("%d%d", &a, &b); 8 printf("%d\n", a + b); 9 scanf("%d%d", &a, &b); 10 printf("%d", a + b); 11 return 0; 12 }
1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int a=0,b=0; 8 while(cin>>a>>b) 9 { 10 cout<<a+b<<endl; 11 12 } 13 14 return 0; 15 }