1F - A+B for Input-Output Practice (III)
Your task is to Calculate a + b.
Input
Input contains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line. A test case containing 0 0 terminates the input and this test case is not to be processed.
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
1 5 10 20 0 0
Sample Output
6 30
// 先上代码对比
1 #include<stdio.h> 2 int main() 3 { 4 int a, b, t, i; 5 while(scanf("%d %d", &a, &b), a!=0&&b!=0) 6 printf("%d\n", a+b); 7 return 0; 8 }
1 #include<stdio.h> 2 int main() 3 { 4 int a, b, t, i; 5 while(scanf("%d %d", &a, &b), !(a==0&&b==0)) 6 printf("%d\n", a+b); 7 return 0; 8 }
//
a!=0 && b!=0 | !(a==0 && b==0) | |
a真b真 | 真 | 真 |
a真b假 | 假 | 真 |
a假b真 | 假 | 真 |
a假b假 | 假 | 假 |
// !(a==0&&b==0) <=> a||b
// 插入补充:命名文件时不要用空格!!!
例如:一开始我把WA的文件命名为“F”,把AC的文件命名为“F test”. 结果运行“F test”的结果和“F”的一样.
后来我运行了如下代码
1 #include<stdio.h> 2 int main() 3 { 4 int a=0, b=2; 5 while(a!=0&&b!=0) 6 { 7 printf("%d\n", a+b); 8 } 9 return 0; 10 }
结果还是和“F”一样!!!大概执行程序的时候读程序名读到空格就结束吧