From db25582ebc2a3786976e3057187aa8426758072e Mon Sep 17 00:00:00 2001 From: VIliam Date: Fri, 26 Apr 2024 01:43:40 +0200 Subject: [PATCH] cv10 --- cv10/program.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cv10/program.c b/cv10/program.c index 57ef575..c9de1b7 100644 --- a/cv10/program.c +++ b/cv10/program.c @@ -11,6 +11,12 @@ int porovnaj_mena(const void *a, const void *b) { } int main() { + int pocet_prijatych; + if (scanf("%d\n", &pocet_prijatych) != 1 || pocet_prijatych <= 0) { + puts("Nespravny vstup"); + return 1; + } + char *pole_smernikov[SIZE]; memset(pole_smernikov, 0, SIZE * sizeof(char *)); int pocet_mien_v_poli = 0; @@ -45,7 +51,8 @@ int main() { qsort(pole_smernikov, pocet_mien_v_poli, sizeof(char *), porovnaj_mena); // Vypísanie zotriedených mien - for (int i = 0; i < pocet_mien_v_poli; i++) { + printf("Prijati studenti:\n"); + for (int i = 0; i < pocet_prijatych && i < pocet_mien_v_poli; i++) { printf("%s\n", pole_smernikov[i]); }