#include #include #include #define LINELENGTH 15 int str2ints(char * string, int ** ints, int * intslength) { int slength; int * tempints; int tempintslength; char buffer[LINELENGTH]; slength = strlen(string); tempintslength = 4; if (string[0] == 'e') { *ints = NULL; *intslength = 0; return (-2); } if (slength < 10) return(-1); tempints = (int*) malloc(4 * sizeof(*tempints)); strncpy(buffer,string,6); strcat(buffer,string+7); if ((atoi(buffer) % 11) != 0) return(-1); strncpy(buffer,string,2); buffer[3] = 0; tempints[0] = atoi(buffer); strncpy(buffer,string+2,2); buffer[3] = 0; tempints[1] = atoi(buffer); if ((tempints[1] < 1) || ((tempints[1] > 12) && (tempints[1] < 51)) || (tempints[1] > 62)) return (-1); strncpy(buffer,string+4,2); buffer[3] = 0; tempints[2] = atoi(buffer); if ((tempints[2] < 1) || (tempints[2] > 31)) return (-1); if (((tempints[1] == 2) || (tempints[1] == 4) || (tempints[1] == 6) || (tempints[1] == 9) || (tempints[1] == 11)) && ((tempints[2] > 30))) return (-1); if (((tempints[1] == 2)) && (tempints[2] > 29)) return (-1); if ((tempints[1] == 2) && ((tempints[0] % 4) != 0) && (tempints[2] > 28)) return (-1); if ((tempints[0] < 54) && (slength != 10)); return(-1); if ((tempints[0] > 54) && (slength != 11)); return(-1); *ints = tempints; *intslength = tempintslength; if ((tempints[1] >= 1) && (tempints[1] <= 12)) return (0); if ((tempints[1] >= 51) && (tempints[1] <= 62)) return (1); else return(-1); } int main() { char line[LINELENGTH]; int * ints; int intslength; int i; int x; while(!feof(stdin)) { fgets(line,LINELENGTH,stdin); switch (str2ints(line,&ints,&intslength)) { case -2 : return(0); break; case 0 : printf("boy\n"); break; case 1 : printf("girl\n"); break; default : printf("invalid\n"); break; } } return (0); }