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;