Aktualizovat „du5/program.c“

This commit is contained in:
Bohdan Yanchyk 2020-04-09 23:28:36 +00:00
parent d50eb79d0f
commit b09f1ccbeb

View File

@ -69,27 +69,28 @@ int main(){
qsort(PersonList,c,sizeof(struct person),comp_num); qsort(PersonList,c,sizeof(struct person),comp_num);
int k =0; int k =0;
for(int i=0; i<c; i++)
for(int i =0;i<c-1;i++){ {
for(int j=i+1;j<c-1-i;j++){ for(int j=i+1; j<c; j++)
if(strcmp(PersonList[i].name,PersonList[j].name)==0){ {
struct person temp = PersonList[j];
PersonList[j] = PersonList[j+1]; if(strcmp(PersonList[i].name,PersonList[j].name)==0)
PersonList[j+1]=temp; {
c--;
flag=1; for(int k=j; k<c; k++)
for (int k=i; k<30; k++){ {
PersonList[k] = PersonList[k]; PersonList[k] = PersonList[k + 1];
} }
c--;
j--;
} }
else{flag=0;} }
}
}
if(flag ==1){
c=1;
} }
printf("Vysledky:\n"); printf("Vysledky:\n");
for(int i =0;i<c;i++){ for(int i =0;i<c;i++){
printf("%d %s\n",PersonList[i].score,PersonList[i].name); printf("%d %s\n",PersonList[i].score,PersonList[i].name);