博客
关于我
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 [Err] 1436 - Thread stack overrun: 129464 bytes used of a 286720 byte stack, and 160000 bytes
查看>>
MySQL _ MySQL常用操作
查看>>
MySQL – 导出数据成csv
查看>>
MySQL —— 在CentOS9下安装MySQL
查看>>
MySQL —— 视图
查看>>
mysql 不区分大小写
查看>>
mysql 两列互转
查看>>
MySQL 中开启二进制日志(Binlog)
查看>>
MySQL 中文问题
查看>>
MySQL 中日志的面试题总结
查看>>
mysql 中的all,5分钟了解MySQL5.7中union all用法的黑科技
查看>>
MySQL 中的外键检查设置:SET FOREIGN_KEY_CHECKS = 1
查看>>
Mysql 中的日期时间字符串查询
查看>>
mysql 中索引的问题
查看>>
MySQL 中锁的面试题总结
查看>>
MySQL 中随机抽样:order by rand limit 的替代方案
查看>>
MySQL 为什么需要两阶段提交?
查看>>
mysql 为某个字段的值加前缀、去掉前缀
查看>>
mysql 主从
查看>>
mysql 主从 lock_mysql 主从同步权限mysql 行锁的实现
查看>>