多数据处理——特殊输入结束
Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 80 Accepted Submission(s) : 63
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
第三类:特殊输入结束
以特定的输入内容结束程序,如每组数据输入两个大于0的数,以输入两个0为结束标志
处理方式,判断输入内容是否与结束标志相同
例:每次输入一个正整数n,当输入为0时结束程序
int main()
{
int n;
while( cin >> n && n ) {
//program
}
return 0;
}
结合上述信息,或查找if语句相关内容,解决以0 0输入结束的a+b问题
以特定的输入内容结束程序,如每组数据输入两个大于0的数,以输入两个0为结束标志
处理方式,判断输入内容是否与结束标志相同
例:每次输入一个正整数n,当输入为0时结束程序
int main()
{
int n;
while( cin >> n && n ) {
//program
}
return 0;
}
结合上述信息,或查找if语句相关内容,解决以0 0输入结束的a+b问题
Input
输入包含多组数据,以0 0结束
A test case with a = b = 0 terminates the input and this test case is not to be processed.
每组数据包含两个正整数a,b ( 1 <= a, b <= 10 )
A test case with a = b = 0 terminates the input and this test case is not to be processed.
每组数据包含两个正整数a,b ( 1 <= a, b <= 10 )
Output
对于每组数据,输出a+b的值
Sample Input
1 2 3 4 0 0
Sample Output
3 7