首页 > 其他 > 详细

【HDU1000】A+B Problem

时间:2016-02-15 18:15:55      阅读:213      评论:0      收藏:0      [点我收藏+]

题目来源:www.acm.hdu.edu.cn

题目编号:1000

 

 /*原题目*/
【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
 
 
/*题目翻译*/
【问题描述】
 计算A+B的值
 
【输入】
 每行包括两个整形数A和B。
 
【输出】
 对于每个示例,在一行中输出A+B的结果。
 
【样例输入】
 1 1
 
【样例输出】
 2
 
 
 
/*题目分析*/

在本题中,你的任务是计算两个整型数A + B之和。

题目的目的主要在于让你能够熟悉OJ中常见的输入输出格式。

 

/*My Code*/

Judge Status : Accepted

Language:C

 

 1 #include<stdio.h>
 2 
 3 int main()
 4 {
 5     int a,b;                          //定义变量
 6     while(scanf("%d %d",&a,&b)!=EOF)  //特别注意此处格式
 7     {
 8         printf("%d\n",a+b);           //多个输出样例,每个后要换行
 9     }
10     return 0;
11 }

 

特别注意,如下代码形式是不正确的(以下代码将被评判为WA)

/*Wrong Code*/

 1 #include<stdio.h>
 2 
 3 int main()
 4 {
 5     int a,b;
 6 //while(1){
 7     scanf("%d %d",&a,&b);
 8     printf("%d",a+b);
 9 //}
10 //若加了while(1)循环则被判为TLM
11 }

 

 

 

【HDU1000】A+B Problem

原文:http://www.cnblogs.com/mading/p/5190843.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!