zoj1001

来源:互联网 发布:极限编程 编辑:程序博客网 时间:2024/05/23 15:07

//C++
#include<iostream>
using namespace std;
int main()
{
 int a, b;
 while (cin >> a >> b)
 {
  cout << a + b << endl;//不加endl,zoj将反馈wrong answer。
   //endl刷新流的缓冲区(stream's buffer)。
 }
 return 0;
}

/************************************************************************************/

//C
#define _CRT_SECURE_NO_DEPRECATE
//vs2013scanf报错
//旧式的scanf在读取数据的时候会根据format指示从缓冲区中读取直至结束,
//但有些时候我们的format指示会有Bug,导致scanf读取了给定的缓冲区以外(数组越界)的数据。
//使用宏定义忽略警告,或者用scanf_s替换scanf
#include <stdio.h>

int main()
{
    int a,b;
    while(scanf("%d %d",&a, &b) != EOF)
        printf("%d\n",a+b);
    return 0;
}

0 0