set函数的应用
来源:互联网 发布:python 运行效率 编辑:程序博客网 时间:2024/06/04 19:49
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 <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <set>#include <string>using namespace std;set<string> ve;int main(){int i,j;i=j=0;string s;while(cin>>s){string t;t.clear() ; //清空字符串t int p=0;for(i=0;i<s.length() ;i++){ if (isalpha(s[i])) //判断是s[i]是不是字母 { p=1; if(s[i]>='A'&&s[i]<='Z') s[i]=s[i]+32; t=t+s[i]; } else { if(p!=0) { ve.insert(t); p=0; t.clear() ; } }}if(p!=0) ve.insert(t); }for(set<string>::iterator it=ve.begin() ;it!=ve.end() ;it++) //将字符串按照字典序输出 cout << *it << endl;return 0;}
- set函数的应用
- STL里set函数的基本应用
- set内各种函数的应用
- hdu1412 set函数的第一次成功应用 超级水题
- SET的应用
- set 的应用
- set的应用
- set的应用
- set的简单应用
- linux set 命令的应用
- multimap和set的应用
- STL Set的综合应用
- Oracle Set命令的应用
- 营业额统计 set的应用
- 有关set的一点应用
- set容器_自定义数据类型排序(仿函数应用)_insert判断返回值(pair的使用)
- 重载set的operator<()函数
- POJ-3481(set的应用)
- 常见的网络协议
- Android应用程序中Java与JavaScript如何交互
- Python的pandas库实战进行一个数据处理的工作
- 利用 openresty balancer_by_lua 实现一个简单的 ip_hash upstream 调度
- CodeForces 701A Cards(水水的玩扑克)
- set函数的应用
- 文字滚动
- kettle Named Parameters
- js的盒子运动效果
- 关于compareTo方法比较次数的研究
- c#抓取页面乱码解决办法
- 办OSUC diploma Q\微491266652[中留服官网]美国学位学历认证俄亥俄州立大学哥伦布分校文凭成绩单留学回国人员证明 Ohio State University,Columbus毕业证
- 时间啊时间
- OC4J Configuration issue. /u01...dbhome_1/oc4j/j2ee/OC4J_DBConsole_orcl-db-01_orcl not found.