From 5be95e0e42c99d5f355418b4c3a6ff12113ef08a Mon Sep 17 00:00:00 2001 From: Bohdan Yanchyk Date: Thu, 9 Apr 2020 22:58:14 +0000 Subject: [PATCH] =?UTF-8?q?Aktualizovat=20=E2=80=9Edu5/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du5/program.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/du5/program.c b/du5/program.c index 36ec581..f1af489 100644 --- a/du5/program.c +++ b/du5/program.c @@ -21,7 +21,7 @@ int comp(const void *p1, const void *p2){ struct person* person1 = (struct person*)p1; struct person* person2 = (struct person*)p2; - return strcmp(person1->name, person2->name); + return strcmp(person1->name, person2->name)>0; } int comp_num(const void *p1, const void *p2){ @@ -49,31 +49,38 @@ int main(){ } if(c>2){ - qsort(PersonList,c,sizeof(struct person),comp); + qsort(PersonList,c,sizeof(struct person),comp); int res_strcmp=0; int idex = 0; for(int i =0;iPersonList[j].score){ + struct person temp = PersonList[j]; + PersonList[j] = PersonList[j+1]; + PersonList[j+1]=temp; + c--; + } + } + + } printf("Vysledky:\n"); @@ -81,4 +88,4 @@ int main(){ printf("%d %s\n",PersonList[i].score,PersonList[i].name); } return 0; -} \ No newline at end of file +}