From 515acee63ab46fd243590a8905626b3b68fbfecf Mon Sep 17 00:00:00 2001 From: VIliam Date: Fri, 22 Mar 2024 00:11:14 +0100 Subject: [PATCH] cv5 --- cv5/program.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cv5/program.c b/cv5/program.c index f93cff4..6bbca35 100644 --- a/cv5/program.c +++ b/cv5/program.c @@ -47,7 +47,7 @@ int main() { } // Načítanie počtu hlasov a mena zo vstupu - if (sscanf(line, "%d %s", &votes, name) != 2) { + if (sscanf(line, "%d %[^\n]", &votes, name) != 2) { printf("Invalid input. Please try again.\n"); continue; } @@ -73,9 +73,9 @@ int main() { qsort(database, size, sizeof(struct student), compare); // Výpis triedenej databázy - printf("\nSorted database:\n"); + printf("\nResults:\n"); for (int i = 0; i < size; i++) { - printf("%s: %d votes\n", database[i].name, database[i].votes); + printf("%d %s\n", database[i].votes, database[i].name); } return 0;