#include <iostream>
#include <ctype.h>
using namespace std;
//#include "class_a.h"
int main(int argc, char *argv[])
{
string line;
int year;
while( 1 )
{
cout << "请输入年(四位整数,范围1900~3000):";
getline(cin, line);
if(line.size() != 4)
{ cout << "输入不是四位,请重新输入!"<< endl;
continue;
}
bool bCheck = true;
for( int i = 0; i < line.size(); i++ )
{
if( !isdigit( line[i]) )
{
bCheck = false;
break;
}
}
if( !bCheck )
{
cout << "输入不是整数类型年,请重新输入!" << endl;
continue;
}
year = atoi( line.c_str() );
if( year <1900 || year >3000 )
{
cout << "输入错误,不在范围内,请重新输入!" << endl;
continue;
}
break;
}
cout << year <<endl;
system("PAUSE");
return EXIT_SUCCESS;
}