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