UVA 10815 Andy's First Dictionary【set】
2024-09-12 07:32:16
题目链接:https://vjudge.net/contest/211547#problem/C
题目大意:
输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出,单词不区分大小写。
Sample Input
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.
Sample Output
a
adventures
blondes
came
disneyland
……
#include<iostream>
#include<string>
#include<set>
#include<sstream>
using namespace std; set<string> dict;
string s, buf; int main() {
while(cin >> s) {
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) //set具有给集合内元素去重和自动排序的功能
cout << *it << "\n";
return ;
}
2018-04-05
最新文章
- CSS系列——前端进阶之路:初涉Less
- Java命令行解析:apache commons-cli
- Windows 7 USB DVD Download Tool
- [转]分享php中四种webservice实现的简单架构方法及实例
- hadoop: hdfs API示例
- C# 面试的“区别”
- IOS第12天(2,UINavigationController导航控制器)
- JS焦点图,JS 多个页面放多个焦点图
- 【CSS sprites (CSS图片精灵) 详解】
- 利用VNC远程登录Linux服务器简易版
- TensorFlow TensorBoard使用
- Beta 冲刺(4/7)
- A1098. Insertion or Heap Sort
- 2.node.js (二)服务器登录注册 与 包的发布
- SQL Server 之 事务与隔离级别实例讲解
- Java面向对象习题
- 四:(之三)制作镜像和一些docker命令
- ubuntu16.04 linux 编译安装apache2.4.33
- [linux] C语言Linux系统编程-socket回声客户端
- CH5105 Cookies【贪心】【线性dp】
热门文章
- Sqoop入门
- Flask最强攻略 - 跟DragonFire学Flask - 第十篇 before_request after_request
- 一套oracle的练习题
- 【Python】批量查询-提取站长之家IP批量查询的结果加强版本v3.0
- Linux驱动技术(三) _DMA编程【转】
- ES系列十一、ES的index、store、_source、copy_to和all的区别
- windows Tomcat apr安装
- bootstrap 的媒体查询
- unbuntu中如何像Windows一样顺畅的切换中英文输入法
- 读SRE Google运维解密有感(一)