《算法笔记》2.10小节——C/C++快速入门->黑盒测试
1000 Problem A A+B 输入输出练习I
//while...EOF型 多点输入测试
#include <stdio.h>
//#include<iostream>
//using namespace std;
int main() {
int a, b;
//while (scanf("%d %d", &a, &b) != EOF) {
while (~scanf("%d %d", &a, &b) ) {
printf("%d\n", a + b);
}
//while(cin>>a>>b)
//{
// cout << a + b << endl;
//}
return 0;
}
1001 Problem B A+B 输入输出练习II
//while(N--)型 多点输入测试
#include <stdio.h>
int main() {
int a, b;
int N;
scanf("%d", &N);
while (N--) {
scanf("%d%d", &a, &b);
printf("%d\n", a + b);
}
return 0;
}
1002 Problem C A+B 输入输出练习III
//while...break型 多点输入测试
#include <stdio.h>
int main() {
int a, b;
//while (scanf("%d%d", &a, &b)!=EOF) {
// if (a == 0 && b == 0) break;
// printf("%d\n", a + b);
//}
while (scanf("%d %d", &a, &b), a || b) { //a || b 即 a!=0 || b!=0
printf("%d\n", a + b);
}
return 0;
}
1003 Problem D A+B 输入输出练习IV
#include <stdio.h>
int main() {
int num,a;
while (scanf("%d", &num)!=EOF) {
if (num==0) break;
int sum = 0;
while (num--) {
scanf("%d", &a);
sum += a;
}
printf("%d\n", sum);
}
return 0;
}
1004 Problem E A+B 输入输出练习V
#include <stdio.h>
int main() {
int N;
scanf("%d", &N);
while (N--) {
int num;
scanf("%d", &num);
int sum = 0, a = 0;
while (num--) {
scanf("%d", &a);
sum += a;
}
printf("%d\n", sum);
}
return 0;
}
1005 Problem F A+B 输入输出练习VI
#include <stdio.h>
int main() {
int num;
while (scanf("%d",&num)!=EOF) {
int a = 0, sum = 0;
while (num--) {
scanf("%d", &a);
sum += a;
}
printf("%d\n", sum);
}
return 0;
}
1006 Problem G A+B 输入输出练习VII
#include <stdio.h>
int main() {
int a,b;
while (scanf("%d%d",&a,&b)!=EOF) {
int sum;
sum = a+b;
printf("%d\n\n", sum);
}
return 0;
}
1007 Problem H A+B 输入输出练习VIII
#include <stdio.h>
int main() {
int N;
scanf("%d", &N);
while (N--) {
int num;
scanf("%d", &num);
int sum = 0, a = 0;
while (num--) {
scanf("%d", &a);
sum += a;
}
printf("%d\n\n", sum);
}
return 0;
}