关于简单的C语言的ACM,
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/10 20:36:20
关于简单的C语言的ACM,
Problem DescriptionYour task is to Calculate a + b.
Too easy?Of course!I specially designed the problem for acm beginners.
You must have found that some problems have the same titles with this one,yes,all these problems were designed for the same aim.
InputThe input will consist of a series of pairs of integers a and b,separated by a space,one pair of integers per line.
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
Sample Output6
30
Authorlcy
RecommendJGShining我的答案是
#include
void main()
{
int a1,a2,a3,b1,b2,b3;
scanf("%d%d%d%d",&a1,&a2,&b1,&b2);
a3=a1+a2;
b3=b1+b2;
printf("%d\n%d\n",a3,b3);
}
提示答案是错的,到底哪里错了呢
Problem DescriptionYour task is to Calculate a + b.
Too easy?Of course!I specially designed the problem for acm beginners.
You must have found that some problems have the same titles with this one,yes,all these problems were designed for the same aim.
InputThe input will consist of a series of pairs of integers a and b,separated by a space,one pair of integers per line.
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
Sample Output6
30
Authorlcy
RecommendJGShining我的答案是
#include
void main()
{
int a1,a2,a3,b1,b2,b3;
scanf("%d%d%d%d",&a1,&a2,&b1,&b2);
a3=a1+a2;
b3=b1+b2;
printf("%d\n%d\n",a3,b3);
}
提示答案是错的,到底哪里错了呢
#include
int main()
{
int a, b;
while(scanf("%d%d",&a,&b)) //一直读取知道输入EOF
printf("%d\n", a+b);
return 0;
}
再问: 网站给的评价是 Time Limit Exceeded
再答: 哪个网站啊,我看看原题描述。你贴下网址。
再问: 麻烦你了 http://acm.hdu.edu.cn/showproblem.php?pid=1089 我知道了 #include int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF) { printf("%d\n", a+b); } return 0; } 谢谢你的帮忙
再答: 搞定了么?恭喜你!加入EOF标志输入结束。其实不加应该也是可以的。
int main()
{
int a, b;
while(scanf("%d%d",&a,&b)) //一直读取知道输入EOF
printf("%d\n", a+b);
return 0;
}
再问: 网站给的评价是 Time Limit Exceeded
再答: 哪个网站啊,我看看原题描述。你贴下网址。
再问: 麻烦你了 http://acm.hdu.edu.cn/showproblem.php?pid=1089 我知道了 #include int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF) { printf("%d\n", a+b); } return 0; } 谢谢你的帮忙
再答: 搞定了么?恭喜你!加入EOF标志输入结束。其实不加应该也是可以的。