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