From 60852f0d1a14433bddd80a6afe0ef5387ad572d2 Mon Sep 17 00:00:00 2001 From: VIliam Date: Fri, 22 Mar 2024 00:07:54 +0100 Subject: [PATCH] cv5 --- cv5/program.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cv5/program.c b/cv5/program.c index aa88d48..f93cff4 100644 --- a/cv5/program.c +++ b/cv5/program.c @@ -38,7 +38,7 @@ int main() { int votes; while (1) { - + printf("Enter votes and student name (or 'q' to quit): "); fgets(line, SIZE, stdin); // Kontrola ukončenia vstupu @@ -46,8 +46,8 @@ int main() { break; } - // Načítanie mena a počtu hlasov zo vstupu - if (sscanf(line, "%s %d", name, &votes) != 2) { + // Načítanie počtu hlasov a mena zo vstupu + if (sscanf(line, "%d %s", &votes, name) != 2) { printf("Invalid input. Please try again.\n"); continue; } @@ -75,9 +75,8 @@ int main() { // Výpis triedenej databázy printf("\nSorted database:\n"); for (int i = 0; i < size; i++) { - printf("%d %s\n", database[i].votes, database[i].name); + printf("%s: %d votes\n", database[i].name, database[i].votes); } return 0; } - \ No newline at end of file