#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 test = 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){ test = 1; } if(strcmp(names[i], "irru") == 0){ test = 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(test){ strcpy(string, ""); } //Print names if(newLines <= lines){ puts("Prijati studenti:"); 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 + test; i++){ printf("%s\n", newNames[i]); } puts("Neprijati studenti:"); for(int i = lines + test; i < newLines; i++){ printf("%s\n", newNames[i]); } } }