看板 C_and_CPP 關於我們 聯絡資訊
※ 引述《cchou0114 (嘻嘻)》之銘言: : 如題 : 我想要將字串排序 : 例如有3個字串 : 分別存在一個字串陣列中 : string word[]; : word[0]="Hello"; : word[1]="World"; : word[2]="Bye"; : 要怎麼把他依照字首順序排序呢 : 變成這樣 : word[0]="Bye"; : word[1]="Hello"; : word[2]="World"; : 求各位大大給個意見或提示 : 謝謝! #include <algorithm> sort(word,word+3, [](auto a, auto b){ return a[0] > b[0]; }); -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.138.244.200 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1462886430.A.726.html
loveflames: 我猜他會跟你說不能用STL 05/10 21:23
Caesar08: 不會那麼慘吧,他都用string了 05/10 21:24
bibo9901: "=>" 是寫錯了吧 05/10 22:08
Caesar08: 是喔 05/10 22:10
soheadsome: 寫其他語言的lambda寫習慣了.... 05/11 07:12
※ 編輯: soheadsome (223.141.203.169), 05/11/2016 18:10:07