Aktualizovat „du5/program.c“

This commit is contained in:
Bohdan Yanchyk 2020-04-09 21:10:04 +00:00
parent 4917c58d10
commit c06227025a

View File

@ -54,35 +54,32 @@ int main(){
int res_strcmp=0; int res_strcmp=0;
int idex = 0; int idex = 0;
for(int i =0;i<c;i++){ for(int i =0;i<c;i++){
res_strcmp = strcmp(PersonList[i].name,PersonList[i+1].name); for(int j = i;j<c;j++){
if(res_strcmp==0){ res_strcmp = strcmp(PersonList[i].name,PersonList[j].name);
PersonList[i-idex].score += PersonList[i+1].score; if(res_strcmp==0){
idex++; PersonList[i-idex].score += PersonList[i+1].score;
} idex++;
else{ c--;
idex=0; for (int j=i+1; j<c; j++){
} PersonList[j] = PersonList[j+1];
}
}
else{
idex=0;
}
}
} }
int flag=0;
qsort(PersonList,c,sizeof(struct person),comp_num);
qsort(PersonList,c,sizeof(struct person),comp_num);
printf("Vysledky:\n"); printf("Vysledky:\n");
for(int i =0;i<c;i++){ for(int i =0;i<c;i++){
if(i+1<c){ printf("%d %s\n",PersonList[i].score,PersonList[i].name);
res_strcmp = strcmp(PersonList[i].name,PersonList[i+1].name);
}
else{
res_strcmp = strcmp(PersonList[i].name,PersonList[i-1].name);
}
if(res_strcmp!=0){
flag=0;
printf("%d %s\n",PersonList[i].score,PersonList[i].name);
}
else if(res_strcmp==0&&flag==0){
flag=1;
printf("%d %s\n",PersonList[i].score,PersonList[i].name);
}
} }
return 0; return 0;
} }