以下是基本思路,詳細code需要妳自己斟酌:
假設給定文件中的單詞不重復,定義std::set<std::string> words; 如果重復可以定義std::multiset<std::string> words
從給定文件中讀取每個單詞並insert到words
按順序遍歷words, 並輸出,所輸出的即是按字典序排好的單詞。