Andy's First Dictionary(思维)
题目链接:https://vjudge.net/contest/320672#problem/K
Description
XY学长刚刚立下了再不过CET就直播xx的flag,为了不真的开启直播模式,XY学长决定好好学习英语。于是他每天都读一篇只包含生词的英语文章,并以自己高达450的智商在一秒钟之内记忆下来。
现在给你一篇XY学长今天要读的文章,请你写一个程序,输出他都学习到了哪些单词。
要求:如果文章中有相同的单词,那么仅仅输出一次;而且如果两个单词只有大小写不同,将他们视为相同的单词。
Input
测试数据将输入一篇文章。不超过5000行,每一行最多200个字符,并以EOF结束。
Output
按照字典序输出他学到的单词,每行输出一个单词,输出单词时所有的字母全部小写。
数据保证最多有5000个需要输出的单词。
样例输入① a a a a a a a a, a a a a a a.
a a a a b a a a. a? a!!!
样例输入② 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.
样例输出①
a
b
样例输出②
a
adventures
blondes
came
disneyland
fork
going
home
in
left
read
road
sign
so
the
they
to
two
went
were
when
Hint
输入可能包含标点符号,但标点符号显然不能算作单词的一部分。
首先是一个循环输入,我不晓得我用string为啥不能循环输入;
然后判断一下是不是字母,如果要是的话,就都换成小写的;
然后,重点就是用set做,我刚开始用循环超时了。
最后迭代器输出,完事!
代码:
#include<bits/stdc++.h>
using namespace std;
char a[300],b[300];
set<string>s;
int main()
{while(scanf("%s",a)!=EOF){int len=strlen(a);for(int i=0;i<len;i++){if(isalpha(a[i])){a[i]=tolower(a[i]);}else a[i]=' ';}string ab=(string)a;stringstream ss(ab);while(ss>>b){s.insert(b);}}for(set<string>::iterator p=s.begin();p!=s.end();p++) cout<<*p<<endl;return 0;
}
Andy's First Dictionary(思维)相关推荐
- 10815 - Andy's First Dictionary
Andy's First Dictionary PS:因为该题排版较麻烦,这里给出OJ网址:UVa10815 - Andy's First Dictionary 输入一个文本,找出所有不同的单词(连续 ...
- UVa 11062 Andy's Second Dictionary(刘汝佳紫书升级题)
在介绍这道题之前,先介绍一下紫书里面和这道题很像的一道题: 紫书P112页 的例题5-3 安迪的第一个字典(Andy's First Dictionary UVa 10815) 原题链接如下: And ...
- 《STL》— UVa10815 Andy's First Dictionary
UVa10815 Andy's First Dictionary 题意:输入一个文本,找出所有不同的单词(连续字母序列),按字典序从小到大输出.单词不分大小写. #include<string& ...
- uvaoj 10815 Andy's First Dictionary set的基本使用
uvaoj 10815 Andy's First Dictionary set的基本使用 将单词去重后按照字典序输出. 代码如下: /********************************* ...
- Andy's First Dictionary
原题及翻译 Andy, 8, has a dream - he wants to produce his very own dictionary. 8岁的安迪有一个梦想--他想自己编一本字典. Thi ...
- 【UVA - 10815】 Andy's First Dictionary(STL+字符处理)
题干: Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for ...
- Andy’s First Dictionary(安迪的第一部词典)
题目: Description Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an e ...
- UVA 10815 Andy's First Dictionary(STL: set)
代码如下: #include <iostream> #include <sstream> #include <stdio.h> #include <set&g ...
- [STL] UVA 10815 安迪的第一个字典 Andy's First Dictionary
1.set 集合 哦....对了,set有自动按照字典序排序功能..... 声明和插入操作 #include <cstdio> #include <vector> #inclu ...
最新文章
- xcode 编译静态库所要注意
- 常见SMT极性元器件识别方法(图解)
- 【问题解决】Processing库安装方法简介
- OpenMP入门教程
- 关键字搜索 c语言,c语言-以关键字搜索程序
- xilinx IP核技术资料
- JDK源码学习笔记——Enum枚举使用及原理
- 多线程爬虫工作流程图 to 子年
- Atom飞行手册翻译: 2.5 查找和替换
- Kafka集群全部断开,然后重启时报“The broker is trying to join the wrong cluster. Configured zookeeper.connect……”问题
- 程序员10大修炼之道,学会这些月入百万不是梦
- 35岁的程序员:第25章,离职
- struts2通配符使用
- android studio卸载找不到uninstall
- 【Linux】用户和用户组|将用户添加到root组中
- LD3320语音识别模块+MP3-TF-16P模块实现语音交互功能
- Redis设计与实现-读书笔记
- 九龙证券|看好2-4月份汽车月度销量增速的逐月改善
- 条码公司的互联网业务调查分析及展望
- 什么软件可以将win窗口进行置顶_【玩转YOGA】第四期:像平板一样使用平板——触屏手势软件GestureSign...