#include #include #include using namespace std; int main() { int rok, mesic, den, tmp; char text[20]; bool spravne; bool chlap; cin.getline(text,20); while (strcmp(text, "end") != 0) { rok = mesic = den = tmp = 0; chlap = true; spravne = true; for(int i=0; i<6; i++) { switch(i) { case 0: tmp = (text[i] - '0'); if (tmp < 0 || tmp > 9) { spravne = false; } rok = tmp*10; break; case 1: tmp = (text[i] - '0'); if (tmp < 0 || tmp > 9) { spravne = false; } rok += tmp; if ((rok >= 10 && rok <= 19) || rok >= 100 || rok < 0) { spravne = false; } break; case 2: tmp = (text[i] - '0'); if (tmp < 0 || tmp > 9) { spravne = false; } mesic = tmp * 10; break; case 3: tmp = (text[i] - '0'); if (tmp < 0 || tmp > 9) { spravne = false; } mesic += tmp; tmp = mesic; if (tmp >= 51) { chlap = false; tmp -= 50; } if( tmp < 1 || tmp > 12) { spravne = false; } break; case 4: tmp = (text[i] - '0'); if (tmp < 0 || tmp > 9) { spravne = false; } den = tmp * 10; break; case 5: tmp = (text[i] - '0'); if (tmp < 0 || tmp > 9) { spravne = false; } den += tmp; switch(mesic) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: if (den < 1 || den > 31) { spravne = false; } break; case 4: case 6: case 9: case 11: if (den < 1 || den > 30) { spravne = false; } break; case 2: if ((rok % 4) == 0) { if (den < 1 || den > 29) { spravne = false; } } else { if (den < 1 || den > 28) { spravne = false; } } } break; } } if (spravne == false) { cout << "invalid" << endl; cin.getline(text,20); continue; } if (text[6] != '/') { cout << "invalid" << endl; cin.getline(text,20); continue; } int znaky = 0; int pocet = 0; for (int i=7; text[i] != '\0'; i++) { pocet++; if (i > 10) { cout << "invalid" << endl; cin.getline(text,20); continue; } if ((text[i] - '0') >= 0 || (text[i] - '0') <= 9) { znaky *= 10; znaky += text[i] - '0'; } else { cout << "invalid" << endl; cin.getline(text,20); continue; } } long long mega = rok; mega *= 100; mega += mesic; mega *= 100; mega += den; int nasobitel = 1; int poc = pocet; for (;pocet >0; pocet--) { nasobitel *= 10; } mega *= nasobitel; mega += znaky; /*cout << rok << endl; cout << mesic << endl; cout << den << endl; cout << znaky << endl; cout << mega << endl;*/ if (poc == 3 && (rok > 53 || rok < 10)) { cout << "invalid" << endl; cin.getline(text,20); continue; } if (poc == 4 && (rok <= 53 && rok >= 10)) { cout << "invalid" << endl; cin.getline(text,20); continue; } if (poc == 4) { if ((mega % 11) != 0) { cout << "invalid" << endl; cin.getline(text,20); continue; } } if (chlap == true) { cout << "boy" << endl; cin.getline(text,20); continue; } else { cout << "girl" << endl; cin.getline(text,20); continue; } } return 0; }