This commit is contained in:
Džubara 2024-03-22 00:11:14 +01:00
parent 60852f0d1a
commit 515acee63a

View File

@ -47,7 +47,7 @@ int main() {
} }
// Načítanie počtu hlasov a mena zo vstupu // 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"); printf("Invalid input. Please try again.\n");
continue; continue;
} }
@ -73,9 +73,9 @@ int main() {
qsort(database, size, sizeof(struct student), compare); qsort(database, size, sizeof(struct student), compare);
// Výpis triedenej databázy // Výpis triedenej databázy
printf("\nSorted database:\n"); printf("\nResults:\n");
for (int i = 0; i < size; i++) { 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; return 0;