acm题目的a+b用c语言怎么写

来源:百度知道 编辑:UC知道 时间:2024/06/18 01:18:47
我写的是#include<stdio.h>
int main()
{
int a, b;
while(scanf("%d %d",&a,&b)==2)
{
printf("%d\n",a+b);
}
return 0;
}
他说wrong answer

唉~~ 兄弟!我觉得没有必要拘泥于这个答案吧~~

这个答案当然是想让你这样写
=============================
int main()
{
int a, b;
while(scanf("%d %d",&a,&b)!=EOF)
{
printf("%d\n",a+b);
}
return 0;
}

这才是他们所谓的标准答案

输入ctrl+z结束输入

但我觉得你写的不错~~ 因为scanf("%d %d",&a,&b)的返回值只有当a b

都正确读入才会是2 只有a读入是1 都没读入就是0 而且结束输入也没问题

坦白的讲 我觉得你这个法子挺好的~~~

#include<stdio.h>
void main()
{int a,b;
scanf("%d %d",&a,&b);
printf("%d\n",a+b);
}
这样就行啦...先输入a,b的值,然后就可以输出a+b的值了。

没弄明白什么意思
scanf("%d %d",&a,&b)==2 这是什么