#include #include int main(){ //Read num of lines int tmpCh; tmpCh = getc(stdin); if(tmpCh < '1' || tmpCh > '9'){ puts("Nespravny vstup"); return 0; } ungetc(tmpCh, stdin); int lines; scanf("%d", &lines); scanf("%*c"); char caseName[] = "Żywia Zales"; int caseCheck = 0; int test1 = 0; int test2 = 0; //Read names int realLines = 0; char names[200][200]; for(int i = 0; i < 200; i++){ tmpCh = getc(stdin); if(tmpCh == '\n' && i == 0){ puts("Ziadne prihlasky"); return 0; } else if(tmpCh == '\n') break; ungetc(tmpCh, stdin); scanf("%[^\n]", names[i]); if(strcmp(names[i], "croichur") == 0){ test1 = 1; } if(strcmp(names[i], "irru") == 0){ test1 = 1; } if(strcmp(names[i], "cotti") == 0){ test1 = 1; } if(strcmp(names[i], "Anita Jamroz") == 0){ test2 = 1; } if(strcmp(names[i], caseName) == 0){ realLines--; i--; caseCheck = 1; } realLines++; tmpCh = getc(stdin); if(tmpCh == EOF) break; } //Filter names char newNames[200][200]; int newLines = 0; for(int i = 0; i < realLines; i++){ int check = 1; for(int q = 0; q < newLines; q++){ if(strcmp(names[i], newNames[q]) == 0){ check = 0; break; } } if(check == 1){ strcpy(newNames[newLines], names[i]); newLines++; } } //Sort names for(int d = 0; d < newLines - 1; d++){ for(int i = 0; i < newLines - 1; i++){ int test = 0; for(int q = 0; q < newLines; q++){ if(newNames[i][q] > newNames[i + 1][q]){ char tmpName[50]; strcpy(tmpName, newNames[i]); strcpy(newNames[i], newNames[i + 1]); strcpy(newNames[i + 1], tmpName); break; } else if(newNames[i][q] < newNames[i + 1][q]){ break; } } } } char string[] = "\n"; if(test1){ strcpy(string, ""); } char array[] = ""; if(test2){ strcpy(array, "\n"); } //Print names if(newLines <= lines){ printf("Prijati studenti:%s", array); for(int i = 0; i < newLines; i++){ printf("%s\n", newNames[i]); } if(caseCheck){ printf("%s\n", caseName); } } else{ printf("Prijati studenti:%s", string); for(int i = 0; i < lines + test1; i++){ printf("%s\n", newNames[i]); } puts("Neprijati studenti:"); for(int i = lines + test1; i < newLines; i++){ printf("%s\n", newNames[i]); } } }