4 回答

TA貢獻(xiàn)1812條經(jīng)驗(yàn) 獲得超5個(gè)贊
是一邏輯值,決定索引向量是否也要返回。注意只對(duì)某些情況有效。查到的參數(shù)說(shuō)明如下:
index.return logical indicating if the ordering index vector should be returned as well; this is only available for a few cases, the default na.last = NA and full sorting of non-factors.

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超5個(gè)贊
1、sort()函數(shù)描述:對(duì)給定區(qū)間所有元素進(jìn)行排序。sort()函數(shù)語(yǔ)法:sort(begin,end),表示一個(gè)范圍。2、sort()函數(shù)舉例:
1 2 3 4 5 6 7 8 9 | #include <algorithm> #include <iostream> using namespace std; main() { int a[11]={2,4,8,5,7,1,10,6,9,3};//a的長(zhǎng)度=待排數(shù)據(jù)個(gè)數(shù)+1 sort(a,a+10);//對(duì)[a,a+10)排序 for(int i=0;i<10;++i) cout<<a[i]<<endl; } |

TA貢獻(xiàn)1841條經(jīng)驗(yàn) 獲得超3個(gè)贊
排序(sort)
語(yǔ)法:
void sort();
void sort( Comp compfunction );
sort()函數(shù)為鏈表排序,默認(rèn)是升序。如果指定compfunction的話,就采用指定函數(shù)來(lái)判定兩個(gè)元素的大小

TA貢獻(xiàn)1809條經(jīng)驗(yàn) 獲得超8個(gè)贊
例如:有個(gè) int a[1000] 的數(shù)組要排序。而比較函數(shù)你已經(jīng)寫(xiě)好了名字是 comp,則這樣寫(xiě):
1 | qsort (a,1000, sizeof ( int ),comp); |
比較函數(shù) comp 如下:
1234 | int comp ( const void *a, const void *b ) { return * ( int * ) a - * ( int * ) b; } |
詳細(xì)的可以查一下關(guān)于 qsort 的說(shuō)明。
- 4 回答
- 0 關(guān)注
- 1072 瀏覽
添加回答
舉報(bào)