Initialization
This commit is contained in:
parent
ac50e1467a
commit
1b2674b560
@ -2,6 +2,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
int compare_names(const void *a, const void *b) {
|
||||||
|
return strcmp(*(const char **)a, *(const char **)b);
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int count;
|
int count;
|
||||||
char buffer[100];
|
char buffer[100];
|
||||||
@ -44,23 +48,15 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort the applications alphabetically
|
// Sort the applications alphabetically
|
||||||
for (int m = 0; m < i - 1; m++) {
|
qsort(applications, i, sizeof(char *), compare_names);
|
||||||
for (int n = m + 1; n < i; n++) {
|
|
||||||
if (strcmp(applications[m], applications[n]) > 0) {
|
|
||||||
char *temp = applications[m];
|
|
||||||
applications[m] = applications[n];
|
|
||||||
applications[n] = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Prijati studenti:");
|
printf("Prijati studenti:\n");
|
||||||
for (j = 0; j < (count < i ? count : i); j++) {
|
for (j = 0; j < (count < i ? count : i); j++) {
|
||||||
printf("%s\n", applications[j]);
|
printf("%s\n", applications[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count < i) {
|
if (count < i) {
|
||||||
printf("Neprijati studenti:");
|
printf("Neprijati studenti:\n");
|
||||||
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