2412 0 0 0
2417 22 0 0
2422 0 0 0
2427 0 0 0
2432 0 0 0
2442 0 0 0
2447 23 12 0
2437 0 0.5 0
2452 0 0 0
2457 0 0 0
2462 0 23 0
2467 0 0 0
2472 0 0 0
2484 0 333 0
以上是我要排序的数据,我用一个结构体储存。
struct CableLoss
{
int fre;
double value[10];
};
fre 表示 第一列的频率
value[10]储存后面的数据。
现在要按照fre排序即可。
我的code如下
CableLoss Atten_2G[20];
int cmp( const void *a ,const void *b)
{
return (*(CableLoss *)a).fre > (*(CableLoss *)b).fre ? 1 : -1;
}
qsort(Atten_2G,count_2G,sizeof(Atten_2G[0]),cmp);
但是发现结果是不对的,是否是结构体中的数组影响。
如何才能正确按照fre排序,value值必须和fre对逐行对应。
暂时没分了,等下追加一下。