66 lines
1.6 KiB
C
66 lines
1.6 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#define MAX_STUDENTS 100
|
|
#define NAME_SIZE 50
|
|
|
|
int main() {
|
|
int max_students, num_accepted = 0, num_students = 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;
|
|
}
|
|
|
|
memset(names, 0, sizeof(names));
|
|
|
|
while (fgets(temp_name, sizeof(temp_name), stdin)!= NULL && num_accepted < max_students) {
|
|
temp_name[strcspn(temp_name, "\n")] = '\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++;
|
|
}
|
|
num_students++;
|
|
}
|
|
|
|
if (num_accepted == 0) {
|
|
printf("Ziadne prihlasky");
|
|
} else {
|
|
printf("Prijati studenti:");
|
|
for (int i = 0; i < num_accepted; i++) {
|
|
printf("%s\n", names[i]);
|
|
}
|
|
printf("%d",num_accepted);
|
|
printf("%d",num_students);
|
|
|
|
if (num_students > num_accepted) {
|
|
printf("Neprijati studenti:");
|
|
for (int i = 0; i < num_students; i++) {
|
|
strcpy(temp_name, names[i]);
|
|
int found = 0;
|
|
for (int j = 0; j < num_accepted; j++) {
|
|
if (strcmp(names[j], temp_name) == 0) {
|
|
found = 1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|