Изменить 'du5/program.c'

This commit is contained in:
Oleksandr Hryshchenko 2021-04-06 15:07:21 +00:00
parent 8d94d553da
commit 8e6618468d

View File

@ -31,6 +31,7 @@ bool addPoints(struct entry* myEntries, int votes, char* name){
void bsortDesc(struct entry* list[80], int s){ void bsortDesc(struct entry* list[80], int s){
int i, j; int i, j;
struct entry* temp; struct entry* temp;
int count = 0;
for (i = 0; i < s - 1; i++) for (i = 0; i < s - 1; i++)
{ {
@ -42,10 +43,14 @@ void bsortDesc(struct entry* list[80], int s){
list[j] = list[j + 1]; list[j] = list[j + 1];
list[j + 1] = temp; list[j + 1] = temp;
} }
else if ((list[j]->votes == list[j + 1]->votes) && (list[j]->name[0] > list[j + 1]->name[0])){ else if (list[j]->votes == list[j + 1]->votes){
temp = list[j]; while (list[j]->name[count] == list[j + 1]->name[count])
list[j] = list[j + 1]; count++;
list[j + 1] = temp; if (list[j]->name[0] > list[j + 1]->name[0]){
temp = list[j];
list[j] = list[j + 1];
list[j + 1] = temp;
}
} }
} }
} }