如果我有一個這樣的數組:在C中的數組QSORT?
2, 4, 6, 0, 0, 0, 0, 0, 0
- 有沒有一種方法,我可以通過排序只是第3個元素,而保留其餘不變的qsort使用?
qsort(arrNumbers, 3, sizeof(int), compare)
會做這份工作嗎?- 確定低於完整數組的元素數量是否僅導致要排序的元素數量?
編輯: 我比較功能是:
int comp(const int * a, const int * b)
if(a==b)
{
return 0;
}
else
{
if(a<b)
{
return -1;
}
else
{
return 1;
}
}
它看起來對嗎?
這裏有一個新穎的想法:把它放在C程序中,看看會發生什麼! –
[manpage](http://www.opengroup.org/sud/sud1/xsh/qsort.htm)是什麼意思? – sehe
你試過了嗎?它應該工作,並且不難嘗試。 – leo