Initialization
This commit is contained in:
parent
c84eed26e6
commit
fd6728dca9
@ -9,7 +9,10 @@ int main() {
|
|||||||
char names[MAX_STUDENTS][NAME_SIZE];
|
char names[MAX_STUDENTS][NAME_SIZE];
|
||||||
char temp_name[NAME_SIZE];
|
char temp_name[NAME_SIZE];
|
||||||
|
|
||||||
scanf("%d", &max_students);
|
printf("Zadajte maximalny pocet studentov: ");
|
||||||
|
fgets(temp_name, sizeof(temp_name), stdin);
|
||||||
|
max_students = atoi(temp_name);
|
||||||
|
|
||||||
if (max_students <= 0 || max_students > MAX_STUDENTS) {
|
if (max_students <= 0 || max_students > MAX_STUDENTS) {
|
||||||
printf("Nespravny vstup\n");
|
printf("Nespravny vstup\n");
|
||||||
return 1;
|
return 1;
|
||||||
@ -17,6 +20,7 @@ int main() {
|
|||||||
|
|
||||||
memset(names, 0, sizeof(names));
|
memset(names, 0, sizeof(names));
|
||||||
|
|
||||||
|
printf("Zadajte mena studentov (maximalne %d):\n", max_students);
|
||||||
while (fgets(temp_name, sizeof(temp_name), stdin) != NULL && num_accepted < max_students) {
|
while (fgets(temp_name, sizeof(temp_name), stdin) != NULL && num_accepted < max_students) {
|
||||||
|
|
||||||
int i, found = 0;
|
int i, found = 0;
|
||||||
@ -38,20 +42,24 @@ int main() {
|
|||||||
if (num_accepted == 0) {
|
if (num_accepted == 0) {
|
||||||
printf("Ziadne prihlasky");
|
printf("Ziadne prihlasky");
|
||||||
} else {
|
} else {
|
||||||
printf("Prijati studenti:");
|
printf("Prijati studenti:\n");
|
||||||
|
qsort(names, num_accepted, sizeof(names[0]), strcmp);
|
||||||
for (int i = 0; i < num_accepted; i++) {
|
for (int i = 0; i < num_accepted; i++) {
|
||||||
printf("%s", names[i]);
|
printf("%s", names[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (num_accepted < num_students) {
|
if (num_accepted < num_students) {
|
||||||
// printf("Neprijati studenti:");
|
printf("Neprijati studenti:\n");
|
||||||
// for (int i = 0; i < max_students; i++) {
|
for (int i = 0; i < max_students; i++) {
|
||||||
// if (names[i][0] == '\0') {
|
if (names[i][0] == '\0') {
|
||||||
// printf("%s", names[i]);
|
continue;
|
||||||
// }
|
}
|
||||||
// }
|
if (num_accepted == 0 || strcmp(names[num_accepted - 1], names[i]) < 0) {
|
||||||
// }
|
printf("%s", names[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user