2020-04-08 14:52:48 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
int main(){
|
2020-04-08 15:05:15 +00:00
|
|
|
//Read num of lines
|
2020-04-08 14:52:48 +00:00
|
|
|
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");
|
|
|
|
|
2020-04-08 15:05:15 +00:00
|
|
|
//Read names
|
2020-04-08 14:52:48 +00:00
|
|
|
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);
|
2020-04-08 14:55:19 +00:00
|
|
|
scanf("%[^\n]", names[i]);
|
2020-04-08 14:52:48 +00:00
|
|
|
realLines++;
|
|
|
|
tmpCh = getc(stdin);
|
|
|
|
if(tmpCh == EOF) break;
|
|
|
|
}
|
|
|
|
|
2020-04-08 15:05:15 +00:00
|
|
|
//Filter names
|
2020-04-08 14:52:48 +00:00
|
|
|
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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-08 15:05:15 +00:00
|
|
|
//Sort names
|
2020-04-08 14:52:48 +00:00
|
|
|
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++){
|
2020-04-08 15:05:15 +00:00
|
|
|
if(newNames[i][q] > newNames[i + 1][q] || newNames[i][q] == -59){
|
2020-04-08 14:52:48 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-08 15:05:15 +00:00
|
|
|
//Print names
|
2020-04-08 14:52:48 +00:00
|
|
|
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]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|