这串代码在做题页面可运行,提交上去也是正确的,但是在vc++和codeblocks上就会显示出这个错误。
[b][Error] 'stoi' was not declared in this scope[/b]
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string str;
int year;
int month;
cin >> str;
if (str.size() == 6)
{
year = stoi(str.substr(0,4));
month = stoi(str.substr(4));
}
else
{
year = stoi(str.substr(0,2));
month = stoi(str.substr(2));
if(year < 22) year += 2000;
else year += 1900;
}
printf("%04d-%02d",year,month);
return 0;
}