#include #include #include #include using namespace std; bool checkDate(string date, bool & isBoy, string afterSlash) { int y,m,d; char buf[3]; buf[0]=date[0]; buf[1]=date[1]; buf[2]=0; sscanf(buf, "%d",&y); buf[0]=date[2]; buf[1]=date[3]; buf[2]=0; sscanf(buf, "%d",&m); buf[0]=date[4]; buf[1]=date[5]; buf[2]=0; sscanf(buf, "%d",&d); if (m>50) { m-=50; isBoy=false; } else { isBoy=true; } if (y>9 && y<20){ return false; } if(m<1 || m>12){ return false; } if(d<1 || d>31) { return false; } int maxDays=0; switch(m){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: maxDays=31; break; case 2: maxDays=(y%4)?28:29; break; default: maxDays=30; break; } if(y>10) y+=1900; else y+=2000; if (!(d<=maxDays)) { return false; } if(y<1954 && afterSlash.length()!=3) { return false; } if(y>=1954 && afterSlash.length()!=4){ return false; } return true; } bool checkModule(string date, string afterSlash){ string wholeNum; wholeNum+=date; wholeNum+=afterSlash; istringstream is(wholeNum); long long ident; is >> ident; return (ident%11)==0; } int main (int argc, char * argv[]){ while(true){ bool good=true; string line, date, afterSlash; char buf[100]; memset(buf, 0, 100); cin.getline(buf,100); line=string(buf); if (line=="end") { return 0; } if(line.length()!=10 && line.length()!=11) { cout << "invalid" << endl; continue; } for(int i=0;i<6;i++) { if (isdigit(line[i])){ date+=line[i]; } else { good=false; } } if(line[6]!='/' || !good){ cout << "invalid" << endl; continue; } for(unsigned int i=7;i