【UVA - 10815】Andy's First Dictionary (set)
Andy's First Dictionary
Description
不提英文了 直接上中文大意吧
XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英语。于是他每天都读一篇只包含生词的英语文章,并以自己高达450的智商在一秒钟之内记忆下来。
现在给你一篇XY学长今天要读的文章,请你写一个程序,输出他都学习到了哪些单词。
要求:如果文章中有相同的单词,那么仅仅输出一次;而且如果两个单词只有大小写不同,将他们视为相同的单词。
Input
测试数据将输入一篇文章。不超过5000行,每一行最多200个字符,并以EOF结束。
Output
按照字典序输出他学到的单词,每行输出一个单词,输出单词时所有的字母全部小写。
数据保证最多有5000个需要输出的单词。
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
fork
going
home
in
left
read
road
sign
so
the
they
to
two
went
were
when
Hint
输入可能包含标点符号,但标点符号显然不能算作单词的一部分。
题目链接:
https://vjudge.net/problem/UVA-10815
既然不重复,且按顺序排列,那自然是用set了。先一个一个读入单词,然后转小写,用字符串输入输出流存进set,然后遍历set即可
AC代码
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define mod 1000000007
#define ll long long
#define INF 0x3f3f3f3f
#define ME0(x) memset(x,0,sizeof(x))
using namespace std;
set<string> world;
set<string> ::iterator it;
string s;
int main()
{
while(cin>>s)
{
int len=s.length();
for(int i=; i<len; i++)
{
if(isalpha(s[i]))//判断是否是英文字母
s[i]=towlower(s[i]);
else
s[i]=' ';
}
string buf;
stringstream ss(s);//stringstream主要是用在將一个字符串分割,(遇到空格,回车)分割,方便统计、存入单词
while(ss>>buf)
world.insert(buf);
}
for(it=world.begin();it!=world.end();it++)//遍历set
cout<<*it<<endl;
}
【UVA - 10815】Andy's First Dictionary (set)的更多相关文章
- UVA 10815:Andy's First Dictionary(STL)
题意:给出一段英文,里面包含一些单词,空格和标点,单词不区分大小写,默认都为小写.按照字典序输出这些单词(这些单词不能有重复,字母全部变成小写) stringstream:包含在头文件#include ...
- 【例题5-3 UVA - 10815】Andy's First Dictionary
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用stringstream来处理中间的标点. ->直接把他变成一个空格. 然后重新输入进去. set默认的字典序就是升序的了. ...
- 【UVA - 10474 】Where is the Marble?(排序)
Where is the Marble? Descriptions: Raju and Meena love to play with Marbles. They have got a lot of ...
- 【Unity3D实战】摇摆直升机开发实战(一)
[Unity3D实战]摇摆直升机开发实战(一) 1.点击[Assets],创建[Sprites]和[Resources]文件夹,然后将所需要的素材导入[Sprites]文件夹中. 2.找到[Sprit ...
- 【gdoi2018 day2】第二题 滑稽子图(subgraph)(性质DP+多项式)
题目大意 [gdoi2018 day2]第二题 滑稽子图(subgraph) 给你一颗树\(T\),以及一个常数\(K\),对于\(T\)的点集\(V\)的子集\(S\). 定义\(f(S)\)为点集 ...
- 【详解】ThreadPoolExecutor源码阅读(三)
系列目录 [详解]ThreadPoolExecutor源码阅读(一) [详解]ThreadPoolExecutor源码阅读(二) [详解]ThreadPoolExecutor源码阅读(三) 线程数量的 ...
- 【详解】ThreadPoolExecutor源码阅读(二)
系列目录 [详解]ThreadPoolExecutor源码阅读(一) [详解]ThreadPoolExecutor源码阅读(二) [详解]ThreadPoolExecutor源码阅读(三) AQS在W ...
- 【详解】ThreadPoolExecutor源码阅读(一)
系列目录 [详解]ThreadPoolExecutor源码阅读(一) [详解]ThreadPoolExecutor源码阅读(二) [详解]ThreadPoolExecutor源码阅读(三) 工作原理简 ...
- 【UOJ#310】【UNR#2】黎明前的巧克力(FWT)
[UOJ#310][UNR#2]黎明前的巧克力(FWT) 题面 UOJ 题解 把问题转化一下,变成有多少个异或和为\(0\)的集合,然后这个集合任意拆分就是答案,所以对于一个大小为\(s\)的集合,其 ...
随机推荐
- non-blocking I/O
https://en.wikipedia.org/wiki/New_I/O_(Java) zh.wikipedia.org/wiki/Java_NIO Java NIO API提供在java.nio套 ...
- Microsoft.AspNetCore.Identity 使用 mysql 报错处理
1.使用mysql 首先要确定mysql connector 支的版本,正面是链接 https://dev.mysql.com/doc/connector-net/en/connector-net-e ...
- iOS信号量
引子: 在取本地联系人列表的时候看到同事用的这么一段代码: dispatch_semaphore_t sema = dispatch_semaphore_create(); ABAddressBook ...
- php设计模式之--组合模式
php组合模式主要用于上下级关系,可以新增叶子和树枝,分析如下代码即可明白组合模式的含义: <?php header('Content-Type:text/html;charset=utf-8' ...
- netstat 参数
Netstat用于显示与IP.TCP.UDP和ICMP协议相关的统计数据,一般用于检验本机各端口的网络连接情况. NETSTAT [-a] [-b] [-e] [-n] [-o] [-p proto] ...
- HDU3065 病毒侵袭持续中 —— AC自动机
题目链接:https://vjudge.net/problem/HDU-3065 病毒侵袭持续中 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...
- 确定mapkeeper使用的leverdb库路径
目前libleveldb的a或so库有三个路径,/usr/lib, /usr/lib/x86_64-linux-gnu , /usr/local/lib 使用 ls -d -1 /usr/lib/* ...
- css 浏览器兼容性问题集合
http://www.xidayun.com/index.php/2016/05/16/941/ 文章取自前端蜂小客
- python3 安装 opencv3 (win10,64bit)
python3只能安装opencv3 (python2安装opencv应该比python3安装的要简单,可参阅网上其他教程) 步骤参考http://stackoverflow.com/quest ...
- ORA-12547: TNS:lost contact
碰到这个ORA-12547: TNS:lost contact的问题,翻了很多资料和METALINK,总结了一下原因: 1 是由于rpm包没有安装,对于我们的生产环境,此包是安装的. admin@p1 ...