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 idex = 0;
for(int i =0;i<c;i++){
res_strcmp = strcmp(PersonList[i].name,PersonList[i+1].name);
for(int j = i;j<c;j++){
res_strcmp = strcmp(PersonList[i].name,PersonList[j].name);
if(res_strcmp==0){
PersonList[i-idex].score += PersonList[i+1].score;
idex++;
c--;
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);
printf("Vysledky:\n");
for(int i =0;i<c;i++){
if(i+1<c){
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;
}