这道题主要用到了set容器和stringstream,用起来非常方便,我第一次见识到,觉得十分的炫酷……

而且,竟然可以将自己写的单词按照字典序排列,真的太酷了。

下面是书上的代码,目前还处于初学状态,所以都是摘抄例题的代码,希望不久之后,我可以用学到的技能自己做出题来。

晚安啦。

#include<iostream>
#include<string>
#include<set>
#include<sstream>
using namespace std; set<string> dict;//string集合 int main(){
string s,buf;
while(cin>>s&&s!="quit"){
for(int i=;i<s.length();i++){
if(isalpha(s[i])) s[i]=tolower(s[i]);
else s[i]=' ';
}
stringstream ss(s);
while(ss>>buf) dict.insert(buf);
}
for(set<string>::iterator it=dict.begin();it !=dict.end();++it)
cout<<*it<<"\n";
return ;
}

最新文章

  1. iOS开发之再探多线程编程:Grand Central Dispatch详解
  2. sudo:有效用户 ID 不是 0,sudo 属于 root 并设置了 setuid 位吗
  3. A Study of WebRTC Security
  4. 在CentOS7上安装RabbitMQ
  5. FZU 2212 Super Mobile Charger(超级充电宝)
  6. iOS-图片拉伸,最常用的图片拉伸操作总结(干货)
  7. 【转】oracle创建表空间
  8. 我的Android 4 学习系列之Intent 和 Broadcast Reciever
  9. android studio导入包后无法import
  10. VSCode自定义配色方案
  11. 【Aladdin Unity3D Shader编程】之三 光照模型(二)
  12. 【转】MySQL乐观锁在分布式场景下的实践
  13. Android官方命令深入分析之Device Monitor
  14. java8_api_stream
  15. DocFetcher 本机文件搜索工具
  16. 2018/11/5 每日分析-test
  17. final修饰的类有什么特点
  18. 本地服务器能ping通,但是ssh及各种端口都访问不到---待整理
  19. SGU 144. Meeting 概率dp 几何概率分布 难度:0
  20. Java.io 包(字节流)

热门文章

  1. MySQL知识篇-nmon监控
  2. HTTP 状态代码的完整列表
  3. 【计算机视觉】【并行计算与CUDA开发】GPU硬解码---CUVID
  4. XML中不能识别&amp;符号, 需要转义吗?
  5. mysql 基础练习题(一)
  6. 详解vue 路由跳转四种方式 (带参数)
  7. Python-基础-文件操作-随机存取
  8. MySQL中的数据库对象
  9. django 支持跨域请求配置
  10. axios配置