Initialization

This commit is contained in:
Kozar 2024-04-25 21:03:39 +02:00
parent 8696372af4
commit 19f7d1fe4c

View File

@ -10,7 +10,7 @@ int main() {
int count;
char buffer[100];
char **applications;
int i, j;
int i, j, accepted_count = 0;
if (scanf("%d", &count) != 1 || count <= 0) {
printf("Nespravny vstup\n");
@ -39,23 +39,24 @@ int main() {
if (!found) {
applications[i] = strdup(buffer);
i++;
accepted_count++;
}
}
if (i == 0) {
if (accepted_count == 0) {
printf("Ziadne prihlasky\n");
return 1;
}
// Sort the applications alphabetically
qsort(applications, i, sizeof(char *), compare_names);
qsort(applications, accepted_count, sizeof(char *), compare_names);
printf("Prijati studenti:");
for (j = 0; j < i; j++) {
for (j = 0; j < accepted_count; j++) {
printf("%s\n", applications[j]);
}
if (count > i) {
if (count < accepted_count) {
printf("Neprijati studenti:");
for (; j < i; j++) {
printf("%s\n", applications[j]);