2022-04-21 18:50:35 +00:00
|
|
|
#include <stdio.h>
|
2022-04-21 18:48:59 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
|
|
|
char database[200][30];
|
|
|
|
char string[30];
|
|
|
|
int error = 0;
|
|
|
|
int count = 0;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
memset(database, 0, sizeof(database));
|
|
|
|
memset(string, 0, 30);
|
|
|
|
char *r;
|
|
|
|
r = fgets(string, 1000, stdin);
|
|
|
|
if (r == NULL)
|
|
|
|
return 0;
|
2022-04-21 19:07:27 +00:00
|
|
|
sscanf(string, "%d", &count);
|
|
|
|
if(strlen(r) == 1 || count < 1) {
|
2022-04-21 18:48:59 +00:00
|
|
|
puts("Nespravny vstup");
|
|
|
|
return 0;
|
|
|
|
}
|
2022-04-21 19:07:27 +00:00
|
|
|
for (int c = 0; c < 30; c++) {
|
|
|
|
if (isalpha(r[c])) {
|
2022-04-21 18:48:59 +00:00
|
|
|
error = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (error != 0) {
|
|
|
|
puts("Nespravny vstup");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while (strlen(r) > 1) {
|
|
|
|
memset(string, 0, 30);
|
|
|
|
r = fgets(string, 30, stdin);
|
|
|
|
if (r == NULL)
|
|
|
|
break;
|
|
|
|
error = 0;
|
|
|
|
for (int j = 0; j < 200; j++) {
|
|
|
|
|
|
|
|
if (strcmp(database[j], string) == 0) {
|
|
|
|
error = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error == 0 && strlen(r) > 1) {
|
|
|
|
strcpy(database[i], r);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-04-21 19:07:27 +00:00
|
|
|
if (i == 0) {
|
2022-04-21 19:16:17 +00:00
|
|
|
puts("Ziadne prihlasky");
|
2022-04-21 18:48:59 +00:00
|
|
|
}
|
|
|
|
for (int j = 0; j < i; j++) {
|
2022-04-21 19:18:37 +00:00
|
|
|
for (int k = 0; k < i; k++) {
|
|
|
|
if (strcmp(database[j], database[k]) < 0) {
|
2022-04-21 18:48:59 +00:00
|
|
|
char buffer[30];
|
2022-04-21 19:18:37 +00:00
|
|
|
//memset(buffer, 0, sizeof(buffer));
|
2022-04-21 18:48:59 +00:00
|
|
|
strcpy(buffer, database[j]);
|
2022-04-21 19:18:37 +00:00
|
|
|
strcpy(database[j], database[k]);
|
|
|
|
strcpy(database[k], buffer);
|
2022-04-21 18:48:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
puts("Prijati studenti:");
|
|
|
|
for (int j = 0; j < i; j++) {
|
|
|
|
if (j == count) {
|
|
|
|
puts("Neprijati studenti:");
|
|
|
|
}
|
|
|
|
printf("%s", database[j]);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|