From 212b8434e1e1cb7255d2d032843b3e4cb2a1b109 Mon Sep 17 00:00:00 2001 From: Matus Tokarcik Date: Thu, 21 Mar 2024 23:10:29 +0100 Subject: [PATCH] cv5 --- cv5/program.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cv5/program.c b/cv5/program.c index c0c6be2..bb3d416 100644 --- a/cv5/program.c +++ b/cv5/program.c @@ -13,7 +13,12 @@ struct student { int compare_students(const void *a, const void *b) { const struct student *student_a = (const struct student *)a; const struct student *student_b = (const struct student *)b; - return (student_b->votes - student_a->votes); + + if (student_a->votes == student_b->votes) { + return strcmp(student_a->name, student_b->name); + } + + return (student_b->votes - student_a->votes); } // Definícia ukazovateľa na vlastný chybový výstup