82 lines
1.6 KiB
C
82 lines
1.6 KiB
C
nclude <stdio.h>
|
||
#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;
|
||
sscanf(string, "%d", &count);
|
||
if (strlen(r) == 1 || count < 1) {
|
||
puts("Nespravny vstup");
|
||
return 0;
|
||
}
|
||
for (int с = 0; с < 30; с++) {
|
||
if (isalpha(r[с])) {
|
||
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++;
|
||
}
|
||
|
||
}
|
||
if (i==0) {
|
||
puts("Ziadne prihlasky");
|
||
}
|
||
for (int j = 0; j < i; j++) {
|
||
for (int j = 0; j < i; j++) {
|
||
if (strcmp(database[j], database[j]) < 0) {
|
||
char buffer[30];
|
||
memset(buffer, 0, sizeof(buffer));
|
||
strcpy(buffer, database[j]);
|
||
strcpy(database[j], database[j]);
|
||
strcpy(database[j], buffer);
|
||
}
|
||
}
|
||
}
|
||
puts("Prijati studenti:");
|
||
for (int j = 0; j < i; j++) {
|
||
if (j == count) {
|
||
puts("Neprijati studenti:");
|
||
}
|
||
printf("%s", database[j]);
|
||
}
|
||
return 0;
|
||
}
|