UVA 10815 Andy's First Dictionary(set的应用)
来源:互联网 发布:鸟倦飞而知还的而用法 编辑:程序博客网 时间:2024/05/24 00:00
Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of words that he knows is, well, not quite enough. Instead of thinking up all the words himself, he has a briliant idea. From his bookshelf he would pick one of his favourite story books, from which he would copy out all the distinct words. By arranging the words in alphabetical order, he is done! Of course, it is a really time-consuming job, and this is where a computer program is helpful.
You are asked to write a program that lists all the different words in the input text. In this problem, a word is defined as a consecutive sequence of alphabets, in upper and/or lower case. Words with only one letter are also to be considered. Furthermore, your program must be CaSe InSeNsItIvE. For example, words like "Apple", "apple" or "APPLE" must be considered the same.
Input
The input file is a text with no more than 5000 lines. An input line has at most 200 characters. Input is terminated by EOF.
Output
Your output should give a list of different words that appears in the input text, one in a line. The words should all be in lower case, sorted in alphabetical order. You can be sure that he number of distinct words in the text does not exceed 5000.
Sample Input
Adventures in DisneylandTwo blondes were going to Disneyland when they came to a fork in theroad. The sign read: "Disneyland Left."So they went home.
Sample Output
aadventuresblondescamedisneylandforkgoinghomeinleftreadroadsignsothetheytotwowentwerewhen
#include <iostream>#include <algorithm>#include <cstdlib>#include <cstdio>#include <ctype.h>#include <set>#include <sstream>using namespace std;int main(){ set<string> word; string s,buf; while(cin>>s) { for(unsigned int i=0;i<s.length();i++) { if(isalpha(s[i])) s[i]=tolower(s[i]); else s[i]=' '; } stringstream p(s); while(p>>buf) word.insert(buf); } for(set<string>::iterator it = word.begin();it != word.end();it++) cout<<*it<<endl; return 0;}
- UVA 10815 Andy's First Dictionary(set的应用)
- Andy's First Dictionary(uva 10815) set用法
- UVA 10815 Andy's First Dictionary(stl,set)
- UVA 10815 Andy's First Dictionary(stringstream,set等)
- 10815 - Andy's First Dictionary(set和stringstream的应用)
- UVA 10815 Andy's First Dictionary 安迪的字典 stl应用 set+string做法
- UVa - 10815 - Andy's First Dictionary(STL - 集合set)
- Set操作UVa 10815Andy's First Dictionary
- UVa 10815 Andy's First Dictionary 【STL】【set】
- UVa 10815 Andy's First Dictionary 【set】【字典序】
- uva-10815-Andy's First Dictionary-stl-set
- set的应用:UVa10815-Andy's First Dictionary
- Andy's First Dictionary(set)
- 集合set练习:Andy's First Dictionary(UVa 10815)代码
- UVA 10815-Andy's First Dictionary(字符串模拟+排序+重复删除||STL-set)
- 紫书章5例三 Andy's First Dictionary, UVA 10815(set)
- uvaoj 10815 Andy's First Dictionary set的基本使用
- UVa OJ 10815-Andy's First Dictionary
- 算法小进步
- HTML——HTML中的特殊符号
- 函数节流与防抖(参考lodash)
- git使用记录
- web前端javaScript仿京东淘宝图片鼠标浮动图片上移效果
- UVA 10815 Andy's First Dictionary(set的应用)
- 微信公众号开发--双色球彩票开奖结果(Java版)
- 面向对象七大设计原则
- 用JS获取地址栏参数的方法
- sparkOnHbase 解决spark读取hbase数据后不能分布式操作
- The C Programming Language 练习题1-21
- vue2使用axios post跳坑,封装成模块
- maven问题汇总
- PAT (Advanced) 1017. Queueing at Bank (25)