博客
关于我
Andy's First Dictionary, UVa 10815
阅读量:563 次
发布时间:2019-03-09

本文共 642 字,大约阅读时间需要 2 分钟。

Andy’s First Dictionary, UVa 10815

//Andy’s First Dictionary, UVa 10815

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

#include 
#include
#include
#include
using namespace std;set
dict; //string集合int main() { string s, buf; while (cin >> s) { for (int i = 0; i < s.size(); i++) { if (isalpha(s[i])) s[i] = tolower(s[i]); else s[i] = ' '; } stringstream ss(s); //创建字符串流 while (ss >> buf) dict.insert(buf); //从ss中得到buf并插入set中 } for (set
::iterator it = dict.begin(); it != dict.end(); it++) //运用迭代器 cout << *it << endl; return 0;} //以上代码利用了set中元素以从小到大排好序这一性质

转载地址:http://uoipz.baihongyu.com/

你可能感兴趣的文章
Mysql 索引问题集锦
查看>>
Mysql 纵表转换为横表
查看>>
mysql 编译安装 window篇
查看>>
mysql 网络目录_联机目录数据库
查看>>
MySQL 聚簇索引&&二级索引&&辅助索引
查看>>
Mysql 脏页 脏读 脏数据
查看>>
mysql 自增id和UUID做主键性能分析,及最优方案
查看>>
Mysql 自定义函数
查看>>
mysql 行转列 列转行
查看>>
Mysql 表分区
查看>>
mysql 表的操作
查看>>
mysql 视图,视图更新删除
查看>>
MySQL 触发器
查看>>
mysql 让所有IP访问数据库
查看>>
mysql 记录的增删改查
查看>>
MySQL 设置数据库的隔离级别
查看>>
MySQL 证明为什么用limit时,offset很大会影响性能
查看>>
Mysql 语句操作索引SQL语句
查看>>
MySQL 误操作后数据恢复(update,delete忘加where条件)
查看>>
MySQL 调优/优化的 101 个建议!
查看>>