[問題] vector & sort() C++
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Dev-C++ 5.4.0 with TDM-GCC 4.7.1 64-bit
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
no
問題(Question):
不知道該如何建置排序結構是好
餵入的資料(Input):
ulist_table是一個2d struct vector
struct ulist_table{
ulist_table(){}
ulist_table(int t, float i, float r) : tid(t), iu(i), ru(r){}
int tid;
float iu;
float ru;
};
twu是一個float型態的vector(size為number of items)
twu[0] = item編號第一個的twu值, 對應的ulist_table為ulist[0][x]
profit也是一個float型態的vector(size跟twu一樣)
預期的正確結果(Expected Output):
希望可以依據twu的大小值以及相對應的profit value正負來對ulist做排序
(不改變原本的vector內容,而是直接產生一個序列)
(比如說item1 item3 item5 .... 等,或者rank 2, 7, 5 ,6...等)
錯誤結果(Wrong Output):
none
程式碼(Code):(請善用置底文網頁, 記得排版)
http://pastie.org/7399393
補充說明(Supplement):
謝謝大家
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.134.26.140
推
04/10 15:37, , 1F
04/10 15:37, 1F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章