作业帮 > 综合 > 作业

一道ACM的入门题:A+B for Input-Output Practice1(入门)DescriptionYour

来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/07/31 17:48:36
一道ACM的入门题
:A+B for Input-Output Practice1(入门)DescriptionYour task is to Calculate a + b.InputInput 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.OutputFor 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 Input1 5
10 20
0 0Sample Output6
30我的答案是:#include
int main()
{
int a,b,s;
while(scanf("%d%d",&a,&b)!=EOF)
if((a!=0)&&(b!=0))
{
s=a+b;
printf("%d\n",s);
}
else printf("");
return 0;
}但提交后是“WRONG ANWSER"请高手指点错在哪了,该怎么改
一道ACM的入门题:A+B for Input-Output Practice1(入门)DescriptionYour
题目说的是,同时输入0的时候结束呀!而你的不是呀!
再问: 该怎么改呢?
再答: #include int main() { int a,b,s; while(scanf("%d%d",&a,&b)!=EOF&&(a||b) printf("%d\n",a+b); return 0;