1.1.1
1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 int a,b,N; 7 cin >> N; 8 while ( cin >>a >>b) 9 { 10 cout << a+b <<endl; 11 } 12 return 0; 13 }
1.1.2
1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 int a,b,N; 7 cin >> N; 8 for (int i = N; i > 0; i--) 9 { 10 cin >>a >>b; 11 cout << a+b <<endl; 12 } 13 14 return 0; 15 }
1.1.3
#include <iostream> using namespace std; int main() { int a,b; while ((cin >>a >>b) && (a||b)) { cout << a+b <<endl; } return 0; }
1.1.4
#include <iostream> using namespace std; #define MAXN 1000 + 10 //不能加分号 int main() { int N; int arr[MAXN] = {0}; // arr[MAXN] ; while ((cin >>N) && N) { int sum = 0; for (int i=N; i>0; i--) { cin >> arr[i]; sum += arr[i]; } cout << sum << endl; } return 0; }
1.1.5
1 #include <iostream> 2 using namespace std; 3 4 #define MAXN 1000 + 10 //不能加分号 5 int main() 6 { 7 int N; 8 int arr[MAXN] = {0}; 9 // arr[MAXN] ; 10 int M; 11 cin >> M; 12 while ((cin >>N) && (M>0)) 13 { 14 M--; 15 int sum = 0; 16 for (int i=N; i>0; i--) 17 { 18 cin >> arr[i]; 19 sum += arr[i]; 20 } 21 cout << sum << endl; 22 } 23 return 0; 24 }
1.1.6
#include <iostream> using namespace std; #define MAXN 1000 + 10 //不能加分号 int main() { int N; int arr[MAXN] = {0}; while ((cin >>N) ) { int sum = 0; for (int i=N; i>0; i--) { cin >> arr[i]; sum += arr[i]; } cout << sum << endl; } return 0; }
1.1.7
1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 int a,b; 7 while (cin >> a >> b) 8 { 9 cout << a+b << endl << endl; 10 } 11 return 0; 12 }
1.1.8
1 #include <iostream> 2 using namespace std; 3 4 #define MAXN 1000 + 10 //不能加分号 5 int main() 6 { 7 int N; 8 int arr[MAXN] = {0}; 9 int M; 10 cin >> M; 11 while ((cin >>N) && (M>0)) 12 { 13 M--; 14 int sum = 0; 15 for (int i=N; i>0; i--) 16 { 17 cin >> arr[i]; 18 sum += arr[i]; 19 } 20 (M!=0)?(cout << sum << endl << endl):(cout << sum <<endl); 21 } 22 return 0; 23 }