Aktualizovat „du5/program.c“

This commit is contained in:
Bohdan Yanchyk 2020-04-09 20:29:40 +00:00
parent 6ad3d99fae
commit b6c2b8eee8

View File

@ -24,6 +24,12 @@ int comp(const void *p1, const void *p2){
return strcmp(person1->name, person2->name); return strcmp(person1->name, person2->name);
} }
int comp_num(const void *p1, const void *p2){
struct person* person1 = (struct person*)p1;
struct person* person2 = (struct person*)p2;
return person1->score<person2->score;
}
int main(){ int main(){
@ -59,8 +65,8 @@ int main(){
} }
int flag=0; int flag=0;
qsort(PersonList,c,sizeof(struct person),comp_num);
printf("Vysledky:\n"); printf("Vysledok\n");
for(int i =0;i<c;i++){ for(int i =0;i<c;i++){
res_strcmp = strcmp(PersonList[i].name,PersonList[i+1].name); res_strcmp = strcmp(PersonList[i].name,PersonList[i+1].name);
if(res_strcmp!=0){ if(res_strcmp!=0){