2011-04-20 35 views
1

我有一個程序,我必須從文本文件中獲取數字,將它們添加到數組中並將它們寫入文件。 我需要使用std :: sort()函數調用對數組中的數字進行排序。我的第一次嘗試是這樣的:在一個數組上使用std :: sort()

void ArrayIntStorage::sortStd() 
{ 
    for (int i = 0; i < n; ++ i) 
    { 
     arrayStorage[i].sort(); 
    } 
} 

「n」是數組大小的常量。我知道這是錯誤的,但我不知道如何去捕捉它。提前致謝。

回答

3

首先讀了排序()的文檔here

取出環,只是嘗試

std::sort(arrayStorage, arrayStorage + n); 
+0

謝謝,有很大的幫助 – TweedyMK 2011-04-20 00:37:56

相關問題