这是一个比较标准的写法,参考一下:
#include
#include
using namespace std;
int main()
{
int a = 0 , b = 1;
cin >> a ;
cout << a << endl ;
if(cin.fail())//如果发生输入错误的话
{
cin.clear(); //清除cin流的错误状态
cin.ignore();//提取并舍弃错误输入
}
cin >> b ;
cout << b << endl;
}
加一句using namespace std; 或者在每个cin和cout前都加上std:: 。
另外,敢问你的work()函数有定义过吗?会报错的。
这样写:
#include
#include
#include
#define fo(x,y,z) for (int x=y;x<=z;x++)
#define N 100001
using namespace std//这句时把标准库里的流类和对象加入到文件中
或者你也可以这样写:
#include
#include
#include
//这里边就直接定义所需要的类和对象了
#define fo(x,y,z) for (int x=y;x<=z;x++)
少一句 ”using namespace std;“或者把#include
你使用的是标注库
需要在包含后面加上using namespace std;
或者直接写成#include