Initialization
This commit is contained in:
parent
8696372af4
commit
19f7d1fe4c
@ -10,7 +10,7 @@ int main() {
|
|||||||
int count;
|
int count;
|
||||||
char buffer[100];
|
char buffer[100];
|
||||||
char **applications;
|
char **applications;
|
||||||
int i, j;
|
int i, j, accepted_count = 0;
|
||||||
|
|
||||||
if (scanf("%d", &count) != 1 || count <= 0) {
|
if (scanf("%d", &count) != 1 || count <= 0) {
|
||||||
printf("Nespravny vstup\n");
|
printf("Nespravny vstup\n");
|
||||||
@ -39,23 +39,24 @@ int main() {
|
|||||||
if (!found) {
|
if (!found) {
|
||||||
applications[i] = strdup(buffer);
|
applications[i] = strdup(buffer);
|
||||||
i++;
|
i++;
|
||||||
|
accepted_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == 0) {
|
if (accepted_count == 0) {
|
||||||
printf("Ziadne prihlasky\n");
|
printf("Ziadne prihlasky\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the applications alphabetically
|
// Sort the applications alphabetically
|
||||||
qsort(applications, i, sizeof(char *), compare_names);
|
qsort(applications, accepted_count, sizeof(char *), compare_names);
|
||||||
|
|
||||||
printf("Prijati studenti:");
|
printf("Prijati studenti:");
|
||||||
for (j = 0; j < i; j++) {
|
for (j = 0; j < accepted_count; j++) {
|
||||||
printf("%s\n", applications[j]);
|
printf("%s\n", applications[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > i) {
|
if (count < accepted_count) {
|
||||||
printf("Neprijati studenti:");
|
printf("Neprijati studenti:");
|
||||||
for (; j < i; j++) {
|
for (; j < i; j++) {
|
||||||
printf("%s\n", applications[j]);
|
printf("%s\n", applications[j]);
|
||||||
|
Loading…
Reference in New Issue
Block a user