(STL,set)安迪的第一个字典
生活随笔
收集整理的這篇文章主要介紹了
(STL,set)安迪的第一个字典
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
問題:
輸入一個文本,找出所有不同的單詞(連續的字母序列),按字典序從小到大輸出。單詞不區分大小寫。
樣例輸入
Adventures in Disneyland
Two blondes were going to Disneyland when they came to a fork in the
road. The sign read: “Disneyland Left.”
So they went home.
樣例輸出
a
adventures
blondes
came
disneyland
fork
going
home
in
left
read
road
sign
so
the
they
to
two
went
were
when
分析與解答
1.set用法
集合元素不重復,已從小到大排好序
具體參見https://blog.csdn.net/qq_40828914/article/details/80657356
2.字符串處理新方法
isalpha判斷是否為字母
tolower(),大寫變小寫
stringstream ss(s);
ss>>buf 輸入字符串,忽略空格
總結
以上是生活随笔為你收集整理的(STL,set)安迪的第一个字典的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 位运算基础知识
- 下一篇: linux查看帮助文档的命令,Linux