From ecf4aa94b82a31fa0c905c9906843db65067c297 Mon Sep 17 00:00:00 2001 From: Andrii Hermaniuk Date: Thu, 7 Apr 2022 16:12:22 +0200 Subject: [PATCH] ds --- du5/program.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/du5/program.c b/du5/program.c index 354b058..ee7ac67 100644 --- a/du5/program.c +++ b/du5/program.c @@ -65,6 +65,12 @@ int find_student(struct student* students,int size, const char* name){ int compare(const void* p1, const void* p2){ struct student* s1 = (struct student*)p1; struct student* s2 = (struct student*)p2; + + int res=(s2->votes)-(s1->votes); + for(int idx=0; res==0||(s1->name[idx])!='\0';idx++){ + res=(int)(s2->name[idx])-(int)(s1->votes[idx]); + } + return (s2->votes)-(s1->votes); }