Mooophy / Cpp-Primer

C++ Primer 5 answers
Creative Commons Zero v1.0 Universal
8.07k stars 2.99k forks source link

Exercise 9_1 (a) #745

Closed oiu850714 closed 4 years ago

oiu850714 commented 4 years ago

這題用 vector 應該比 list 好? 將固定數目的單字 push_back 到 vector 後再對 vector sort 即可達成需求

pezy commented 4 years ago

审题:

inserting them in the container alphabetically as they are entered

要求插入时就维持字母序,而并非全部插入后再排序。

再说了,std::list 不能 sort 吗?

oiu850714 commented 4 years ago

抱歉沒看清楚題目...

不過 std::list 只能用 std::sort::list,且這是在第十章才說明的