博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA 10815 Andy's First Dictionary【set】
阅读量:4311 次
发布时间:2019-06-06

本文共 956 字,大约阅读时间需要 3 分钟。

题目链接:

 

题目大意:

输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出,单词不区分大小写。

 

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
#include
#include
#include
using namespace std;set
dict;string s, buf;int main() { while(cin >> s) { for(int i = 0; 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
::iterator it = dict.begin(); it != dict.end(); ++it) //set具有给集合内元素去重和自动排序的功能 cout << *it << "\n"; return 0;}

 

2018-04-05

转载于:https://www.cnblogs.com/00isok/p/8722099.html

你可能感兴趣的文章
ShuffleNet总结
查看>>
前后台验证字符串长度
查看>>
《算法导论 - 思考题》7-1 Hoare划分的正确性
查看>>
UVa 10491 奶牛和轿车(全概率公式)
查看>>
[Hadoop]-HDFS-架构篇
查看>>
Metronic-最优秀的基于Bootstrap的响应式网站模版
查看>>
20. Valid Parentheses
查看>>
IOS 简单的动画自定义方法(旋转、移动、闪烁等)
查看>>
js/jquery 实时监听输入框值变化的完美方案:oninput & onpropertychange
查看>>
axios
查看>>
PostgreSQL导出一张表到MySQL
查看>>
MVC 前台向后台传输数据
查看>>
《少年先疯队》第四次作业:项目需求调研与分析
查看>>
IPv6 Scapy Samples
查看>>
Asp.Net Ajax的两种基本开发模式
查看>>
哈希——并查集结构——岛问题
查看>>
正则表达式
查看>>
图像处理笔记(十二)
查看>>
条件数(condition number)
查看>>
Chapter 3 Phenomenon——9
查看>>