我有一个 3D 数组:float input[2][50][1000];
我想快速排序:
qsort (x, sizeof(x)/sizeof(*x), sizeof(*x), comp);
补偿在哪里
int comp (const void * elem1, const void * elem2) {
float f = *((float*)elem1);
float s = *((float*)elem2);
if (f > s) return 1;
if (f < s) return -1;
return 0;
}
我只想对我的 3D 数组的 1 维进行排序,即我想对 input[0][temp][0]
、input[0][temp][1 ]
, input[0][temp][2]
等等。
问题:我应该用什么替换x
?
如果听起来很愚蠢,请原谅我
最佳答案
float (*x)[1000] = &input[0][temp];
qsort (x, sizeof(*x)/sizeof(**x), sizeof(**x), comp);
关于c - qsort : Sort 1 Dimension of 3D array in C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23027563/