一个ACM的A+B问题因为我是初学者,想试试ACM,但是A+B就wrong answer了Problem DescriptionCalculate A + B .InputEach line will contain two integers A and B .Process to end of file.OutputFor each case,output A + B in one line.Sample Input1
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/06 17:01:10
![一个ACM的A+B问题因为我是初学者,想试试ACM,但是A+B就wrong answer了Problem DescriptionCalculate A + B .InputEach line will contain two integers A and B .Process to end of file.OutputFor each case,output A + B in one line.Sample Input1](/uploads/image/z/10352868-60-8.jpg?t=%E4%B8%80%E4%B8%AAACM%E7%9A%84A%2BB%E9%97%AE%E9%A2%98%E5%9B%A0%E4%B8%BA%E6%88%91%E6%98%AF%E5%88%9D%E5%AD%A6%E8%80%85%2C%E6%83%B3%E8%AF%95%E8%AF%95ACM%2C%E4%BD%86%E6%98%AFA%2BB%E5%B0%B1wrong+answer%E4%BA%86Problem+DescriptionCalculate+A+%2B+B+.InputEach+line+will+contain+two+integers+A+and+B+.Process+to+end+of+file.OutputFor+each+case%2Coutput+A+%2B+B+in+one+line.Sample+Input1)
一个ACM的A+B问题因为我是初学者,想试试ACM,但是A+B就wrong answer了Problem DescriptionCalculate A + B .InputEach line will contain two integers A and B .Process to end of file.OutputFor each case,output A + B in one line.Sample Input1
一个ACM的A+B问题
因为我是初学者,想试试ACM,但是A+B就wrong answer了
Problem Description
Calculate A + B .
Input
Each line will contain two integers A and B .Process to end of file.
Output
For each case,output A + B in one line.
Sample Input
1 1
Sample Output
2
下面是我写的
# include
int main()
{
int a,b,sum;
scanf("%d,%d",&a,&b);
sum=a+b;
printf("%d",sum);
return 0;
}
为什么会wrong呢,那该怎么写呢,用C写
一个ACM的A+B问题因为我是初学者,想试试ACM,但是A+B就wrong answer了Problem DescriptionCalculate A + B .InputEach line will contain two integers A and B .Process to end of file.OutputFor each case,output A + B in one line.Sample Input1
# include
int main()
{
int a,b,sum;
scanf("%d%d",&a,&b);//去掉逗号,题目中是以空格分开的
sum=a+b;
printf("%d",sum);
return 0;
}
在OJ的评判系统中,一般后台有多组测试数据,而你的代码里只能得出一组,可以改成
# include
int main()
{
int a,b,sum;
while (scanf("%d%d",&a,&b) != EOF)
{
sum=a+b;<...
全部展开
在OJ的评判系统中,一般后台有多组测试数据,而你的代码里只能得出一组,可以改成
# include
int main()
{
int a,b,sum;
while (scanf("%d%d",&a,&b) != EOF)
{
sum=a+b;
printf("%d\n",sum);
}
return 0;
}
收起