2024-04-22 12:01:17 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2024-04-22 12:06:40 +00:00
|
|
|
#define MAX_STUDENTS 100
|
|
|
|
#define NAME_SIZE 50
|
2024-04-22 12:01:17 +00:00
|
|
|
|
|
|
|
int main() {
|
2024-04-22 12:06:40 +00:00
|
|
|
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;
|
|
|
|
}
|
2024-04-22 12:01:17 +00:00
|
|
|
|
2024-04-22 12:21:38 +00:00
|
|
|
// Initialize the names array to all-zero strings
|
2024-04-22 12:16:34 +00:00
|
|
|
memset(names, 0, sizeof(names));
|
|
|
|
|
2024-04-22 12:11:09 +00:00
|
|
|
while (fgets(temp_name, sizeof(temp_name), stdin) != NULL && num_accepted < max_students) {
|
2024-04-22 12:21:38 +00:00
|
|
|
// Remove newline character from temp_name
|
2024-04-22 12:11:09 +00:00
|
|
|
|
2024-04-22 12:06:40 +00:00
|
|
|
int i, found = 0;
|
2024-04-22 12:01:17 +00:00
|
|
|
|
2024-04-22 12:06:40 +00:00
|
|
|
for (i = 0; i < num_accepted; i++) {
|
|
|
|
if (strcmp(names[i], temp_name) == 0) {
|
2024-04-22 12:01:17 +00:00
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
2024-04-22 12:06:40 +00:00
|
|
|
strcpy(names[num_accepted], temp_name);
|
|
|
|
num_accepted++;
|
2024-04-22 12:01:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-22 12:06:40 +00:00
|
|
|
if (num_accepted == 0) {
|
|
|
|
printf("Ziadne prihlasky\n");
|
|
|
|
} else {
|
2024-04-22 12:15:10 +00:00
|
|
|
printf("Prijati studenti:\n");
|
2024-04-22 12:06:40 +00:00
|
|
|
for (int i = 0; i < num_accepted; i++) {
|
2024-04-22 15:39:49 +00:00
|
|
|
printf("%s", names[i]);
|
|
|
|
if (i < num_accepted - 1) {
|
|
|
|
printf("\n");
|
|
|
|
}
|
2024-04-22 12:06:40 +00:00
|
|
|
}
|
2024-04-22 12:01:17 +00:00
|
|
|
}
|
|
|
|
|
2024-04-22 12:06:40 +00:00
|
|
|
if (num_accepted < max_students) {
|
|
|
|
printf("Neprijati studenti:\n");
|
|
|
|
for (int i = num_accepted; i < max_students; i++) {
|
2024-04-22 12:21:38 +00:00
|
|
|
printf("%s", names[i]);
|
2024-04-22 12:06:40 +00:00
|
|
|
}
|
2024-04-22 12:01:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|