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