Re: [問題] c++將字串排序
※ 引述《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
推
05/10 21:23, , 1F
05/10 21:23, 1F
→
05/10 21:24, , 2F
05/10 21:24, 2F
→
05/10 22:08, , 3F
05/10 22:08, 3F
→
05/10 22:10, , 4F
05/10 22:10, 4F
→
05/11 07:12, , 5F
05/11 07:12, 5F
※ 編輯: soheadsome (223.141.203.169), 05/11/2016 18:10:07
討論串 (同標題文章)