[問題] vector & sort() C++

看板C_and_CPP (C/C++)作者 (xTH)時間13年前 (2013/04/10 12:48), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
開發平台(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
要另產生排好的序列的話複製一個出來再 sort 就好啦
04/10 15:37, 1F
文章代碼(AID): #1HPEyJ_3 (C_and_CPP)
文章代碼(AID): #1HPEyJ_3 (C_and_CPP)