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 +}