cv5
This commit is contained in:
parent
019daadb45
commit
60852f0d1a
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user