This commit is contained in:
Weber 2024-03-22 00:35:12 +00:00
parent 86a5ea47e0
commit 589aeab644

View File

@ -55,24 +55,19 @@ int main() {
students[student_count].name = strdup(name); students[student_count].name = strdup(name);
students[student_count].vote_count = vote_count; students[student_count].vote_count = vote_count;
student_count++; student_count++;
}
}
if (student_count == 1) { if (student_count == 1) {
printf("Vysledky:\n"); printf("Vysledky:\n");
printf("%d %s\n", students[0].vote_count, students[0].name); printf("%d %s\n", students[0].vote_count, students[0].name);
} else {
free(students[0].name);
free(students);
return 0;
}
}
}
qsort(students, student_count, sizeof(student_t), compare_students); qsort(students, student_count, sizeof(student_t), compare_students);
printf("Vysledky:\n"); printf("Vysledky:\n");
for (int i = 0; i < student_count; i++) { for (int i = 0; i < student_count; i++) {
printf("%d %s\n", students[i].vote_count, students[i].name); printf("%d %s\n", students[i].vote_count, students[i].name);
} }
}
for (int i = 0; i < student_count; i++) { for (int i = 0; i < student_count; i++) {
free(students[i].name); free(students[i].name);