2333
This commit is contained in:
parent
6193855475
commit
df4e8d802d
@ -15,6 +15,13 @@ int main() {
|
||||
memset(pole_smernikov, 0, SIZE * sizeof(char*));
|
||||
int pocet_mien_v_poli = 0;
|
||||
|
||||
// Načítanie maximálneho počtu študentov
|
||||
int max_students;
|
||||
if (scanf("%d\n", &max_students) != 1 || max_students <= 0) {
|
||||
puts("Nespravny vstup");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char line[SIZE];
|
||||
while (fgets(line, SIZE, stdin) != NULL) {
|
||||
line[strcspn(line, "\n")] = 0; // Remove the newline character
|
||||
@ -37,22 +44,25 @@ int main() {
|
||||
}
|
||||
}
|
||||
|
||||
if (pocet_mien_v_poli == 0) {
|
||||
puts("Ziadne prihlasky");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Triedenie
|
||||
qsort(pole_smernikov, pocet_mien_v_poli, sizeof(char*), compare);
|
||||
|
||||
// Výpis prijatých a neprijatých študentov
|
||||
int max_students;
|
||||
fgets(line, SIZE, stdin);
|
||||
sscanf(line, "%d", &max_students);
|
||||
|
||||
printf("Prijati studenti:\n");
|
||||
puts("Prijati studenti:");
|
||||
for (int i = 0; i < max_students && i < pocet_mien_v_poli; i++) {
|
||||
printf("%s\n", pole_smernikov[i]);
|
||||
}
|
||||
|
||||
printf("Neprijati studenti:\n");
|
||||
for (int i = max_students; i < pocet_mien_v_poli; i++) {
|
||||
printf("%s\n", pole_smernikov[i]);
|
||||
if (max_students < pocet_mien_v_poli) {
|
||||
puts("Neprijati studenti:");
|
||||
for (int i = max_students; i < pocet_mien_v_poli; i++) {
|
||||
printf("%s\n", pole_smernikov[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Uvoľnenie pamäte
|
||||
|
Loading…
Reference in New Issue
Block a user