56 lines
1.3 KiB
C
56 lines
1.3 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#define MAX_STUDENTS 100
|
|
#define NAME_SIZE 50
|
|
|
|
int main() {
|
|
int max_students, num_accepted = 0;
|
|
char names[MAX_STUDENTS][NAME_SIZE];
|
|
char temp_name[NAME_SIZE];
|
|
|
|
scanf("%d", &max_students);
|
|
if (max_students <= 0 || max_students > MAX_STUDENTS) {
|
|
printf("Nespravny vstup\n");
|
|
return 1;
|
|
}
|
|
|
|
while (fgets(temp_name, sizeof(temp_name), stdin) != NULL && num_accepted < max_students) {
|
|
size_t len = strlen(temp_name);
|
|
if (len > 0 && temp_name[len-1] == '\n') {
|
|
temp_name[len-1] = '\0';
|
|
}
|
|
|
|
int i, found = 0;
|
|
|
|
for (i = 0; i < num_accepted; i++) {
|
|
if (strcmp(names[i], temp_name) == 0) {
|
|
found = 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!found) {
|
|
strcpy(names[num_accepted], temp_name);
|
|
num_accepted++;
|
|
}
|
|
}
|
|
|
|
if (num_accepted == 0) {
|
|
printf("Ziadne prihlasky\n");
|
|
} else {
|
|
printf("Prijati studenti:\n");
|
|
for (int i = 0; i < num_accepted; i++) {
|
|
printf("%s", names[i]);
|
|
}
|
|
}
|
|
|
|
if (num_accepted < max_students) {
|
|
printf("Neprijati studenti:\n");
|
|
for (int i = num_accepted; i < max_students; i++) {
|
|
printf("%s", names[i]);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
} |