@H_403_1@我使用stdlib.h中的qsort,
void qsort (void* base,size_t num,size_t size,int (*compar)(const void*,const void*));
以下列方式:
void myfun (float *arr,int n,float c) // value of c is changeable { ...// some code qsort(float *arr,n,sizeof(float),compareme); ...// some code }
同
int compareme (const void * a,const void * b) { float tmp = f((float*)a,(float*)b,c ); // f is some function,and how can I pass c here? if (tmp < 0) return -1; if (tmp == 0) return 0; if (tmp > 0) return 1; }
我怎样才能在比较中使用c?
谢谢!