pray
This commit is contained in:
parent
924e6cea5b
commit
3e76694b5e
BIN
cv2/program
BIN
cv2/program
Binary file not shown.
@ -43,25 +43,30 @@ int main() {
|
||||
helper++;
|
||||
}
|
||||
|
||||
counter2 = (counter2 / 2) - 1;
|
||||
counter2 = (counter2 / 2);
|
||||
qsort(databaza, counter2,sizeof(struct jedlo),compare);
|
||||
|
||||
while(counter2 >= 0){
|
||||
printf("%s", databaza[counter2].name);
|
||||
printf("%f\n", databaza[counter2].price);
|
||||
counter2--;
|
||||
for(int z=0; z<counter2; z++){
|
||||
printf("%s", databaza[z].name);
|
||||
printf("%f\n", databaza[z].price);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int compare(const void* p1,const void*p2){
|
||||
struct jedlo* s1=(struct jedlo*)p1;
|
||||
struct jedlo* s2=(struct jedlo*)p2;
|
||||
struct jedlo s1 = *(const struct jedlo*)p1;
|
||||
struct jedlo s2 = *(const struct jedlo*)p2;
|
||||
|
||||
if(s1->price == s2->price){
|
||||
return 0;
|
||||
int order;
|
||||
|
||||
if(s1.price > s2.price){
|
||||
order = 1;
|
||||
}
|
||||
else if(s1->price < s2->price){
|
||||
return 1;
|
||||
else if(s1.price < s2.price){
|
||||
order = -1;
|
||||
}
|
||||
return -1;
|
||||
else {
|
||||
order = 0;
|
||||
}
|
||||
return order;
|
||||
}
|
Loading…
Reference in New Issue
Block a user