From 589aeab64437f48b74b836a1f4ba9e5b434ef6ec Mon Sep 17 00:00:00 2001 From: Weber Date: Fri, 22 Mar 2024 00:35:12 +0000 Subject: [PATCH] test --- cv5/program.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/cv5/program.c b/cv5/program.c index 67acae3..db90962 100644 --- a/cv5/program.c +++ b/cv5/program.c @@ -55,23 +55,18 @@ int main() { students[student_count].name = strdup(name); students[student_count].vote_count = vote_count; student_count++; - - if (student_count == 1) { - printf("Vysledky:\n"); - printf("%d %s\n", students[0].vote_count, students[0].name); - - free(students[0].name); - free(students); - return 0; - } } } - qsort(students, student_count, sizeof(student_t), compare_students); - - printf("Vysledky:\n"); - for (int i = 0; i < student_count; i++) { - printf("%d %s\n", students[i].vote_count, students[i].name); + if (student_count == 1) { + printf("Vysledky:\n"); + printf("%d %s\n", students[0].vote_count, students[0].name); + } else { + qsort(students, student_count, sizeof(student_t), compare_students); + printf("Vysledky:\n"); + for (int i = 0; i < student_count; i++) { + printf("%d %s\n", students[i].vote_count, students[i].name); + } } for (int i = 0; i < student_count; i++) {