题目链接:https://vjudge.net/contest/211547#problem/C

题目大意:

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

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

2018-04-05

最新文章

  1. CSS系列——前端进阶之路:初涉Less
  2. Java命令行解析:apache commons-cli
  3. Windows 7 USB DVD Download Tool
  4. [转]分享php中四种webservice实现的简单架构方法及实例
  5. hadoop: hdfs API示例
  6. C# 面试的“区别”
  7. IOS第12天(2,UINavigationController导航控制器)
  8. JS焦点图,JS 多个页面放多个焦点图
  9. 【CSS sprites (CSS图片精灵) 详解】
  10. 利用VNC远程登录Linux服务器简易版
  11. TensorFlow TensorBoard使用
  12. Beta 冲刺(4/7)
  13. A1098. Insertion or Heap Sort
  14. 2.node.js (二)服务器登录注册 与 包的发布
  15. SQL Server 之 事务与隔离级别实例讲解
  16. Java面向对象习题
  17. 四:(之三)制作镜像和一些docker命令
  18. ubuntu16.04 linux 编译安装apache2.4.33
  19. [linux] C语言Linux系统编程-socket回声客户端
  20. CH5105 Cookies【贪心】【线性dp】

热门文章

  1. Sqoop入门
  2. Flask最强攻略 - 跟DragonFire学Flask - 第十篇 before_request after_request
  3. 一套oracle的练习题
  4. 【Python】批量查询-提取站长之家IP批量查询的结果加强版本v3.0
  5. Linux驱动技术(三) _DMA编程【转】
  6. ES系列十一、ES的index、store、_source、copy_to和all的区别
  7. windows Tomcat apr安装
  8. bootstrap 的媒体查询
  9. unbuntu中如何像Windows一样顺畅的切换中英文输入法
  10. 读SRE Google运维解密有感(一)