Update 'cv2/program.c'
This commit is contained in:
parent
c7eaa87507
commit
adc2849984
@ -29,20 +29,14 @@ int read_pizza(struct pizza* item){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
int comparename(const void *a, const void *b){
|
||||
|
||||
struct pizza* pizza_a = (void*) a;
|
||||
struct pizza* pizza_b = (void*) b;
|
||||
int compare(const void *a, const void *b){
|
||||
|
||||
return strcmp(pizza_a->name, pizza_b->name);
|
||||
|
||||
}
|
||||
int compareprize(const void *a, const void *b){
|
||||
|
||||
struct pizza* pizza_a = (void*) a;
|
||||
struct pizza* pizza_b = (void*) b;
|
||||
|
||||
float r = (pizza_a->prize > pizza_b->prize) - (pizza_a->prize < pizza_b->prize);
|
||||
if (r == 0){
|
||||
r = strcmp(pizza_a->name, pizza_b->name);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -60,7 +54,7 @@ int main(){
|
||||
counter++;
|
||||
}
|
||||
|
||||
qsort(jedalny_listok, counter, sizeof(struct pizza), compareprize);
|
||||
qsort(jedalny_listok, counter, sizeof(struct pizza), compare);
|
||||
|
||||
int i = 0;
|
||||
for(i = 0; i < counter; i++){
|
||||
@ -68,7 +62,5 @@ int main(){
|
||||
printf("%f", jedalny_listok[i].prize);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user