BOJ 83 A + B Problem

时间限制 1000 ms 内存限制 65536 KB

题目描述

Calculate the sum of two given integers A and B.

输入格式

The input consists of a line with A and B(10^4A,B10^4).

输出格式

Output the only answer.

输入样例

2 3

输出样例

5


#include<stdio.h>
 
 int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%d",a+b);
    return 0;
 }

忘写“\n”了,虽然也通过了但是查看时发现只走了一个测试用例,得了10分。

#include <stdio.h> 
    
main() 
{ 
    int a,b; 
    while(scanf("%d%d",&a,&b)!=EOF) 
        printf("%d\n",a+b); 
    return 0; 
} 

EOF不要倒也没什么影响。

话说C++里怎么判断EOF啊。。。o(╯□╰)o

男票说C用main()不用 int main(),BOJ上都OK,不过搜了一下,C89 接受main(),C99只有两种:

  int main(void)

  int main(int argc, char *argv[])

C++98中定义了如下两种main函数的定义方式:

  int main( )

  int main(int argc, char *argv[])


从来都没写过int main (void)的路过……总之!记住main 只接受int 返回值就是啦!

另外return 0 时不时会忘,查了一下一般会自动补齐,不过有的不会……So,莫再忘啦。

 
 
posted @ 2014-04-20 14:36  Pudding_AI  阅读(184)  评论(0编辑  收藏  举报