diff --git a/cv10/program.c b/cv10/program.c index 520a872..de71e14 100644 --- a/cv10/program.c +++ b/cv10/program.c @@ -10,7 +10,7 @@ int main() { int count; char buffer[100]; char **applications; - int i; + int i, j; if (scanf("%d", &count) != 1 || count <= 0) { printf("Nespravny vstup\n"); @@ -30,7 +30,7 @@ int main() { buffer[len - 1] = '\0'; } int found = 0; - for (int j = 0; j < i; j++) { + for (j = 0; j < i; j++) { if (strcmp(applications[j], buffer) == 0) { found = 1; break; @@ -51,12 +51,19 @@ int main() { qsort(applications, i, sizeof(char *), compare_names); printf("Prijati studenti:"); - for (int j = 0; j < i; j++) { + for (j = 0; j < i; j++) { printf("%s\n", applications[j]); } + if (count < i) { + printf("Neprijati studenti:"); + for (; j < i; j++) { + printf("%s\n", applications[j]); + } + } + // Free allocated memory - for (int j = 0; j < i; j++) { + for (j = 0; j < i; j++) { free(applications[j]); } free(applications);