#include
#include
using namespace std;
string str;
string month[12] = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" };
int main()
{
cin >> str;
for (int i = 1; i < 13; i++)
{
if (str.substr(0, 3) == month[i])
{
cout << i + 1 << " ";
}
}
if (str[3] != '0')
{
cout << str[3];
}
cout << str[4];
return 0;
}
因为编译器的原因,dev很严格,你总共是12个月,i不应该从1开始,应该从0开始。你设置1~12,12超出了string数组的范围,所以异常退出了。