10815 - Andy's First Dictionary
来源:互联网 发布:剑三男捏脸数据 编辑:程序博客网 时间:2024/06/06 02:31
Andy’s First Dictionary
PS:因为该题排版较麻烦,这里给出OJ网址:UVa10815 - Andy’s First Dictionary
输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出。单词不区分大小写。
#include <iostream>#include <string>#include <set>#include <sstream>using namespace std;// string集合set<string> dict;int main() { string s, buf; while(cin >> s) { for(int i = 0; i < s.length(); i++) { // 字母则小写,非字母则空格 if(isalpha(s[i])) { s[i] = tolower(s[i]); } else { s[i] = ' '; } } // stringstream以空格和回车换行作为分隔符 stringstream ss(s); while(ss >> buf) { dict.insert(buf); } } set<string>::iterator it; for(it = dict.begin(); it != dict.end(); ++it) { cout << *it << endl; } return 0;}
0 0
- 10815--Andy's First Dictionary
- 10815 Andy's First Dictionary
- 10815 - Andy's First Dictionary
- 10815 - Andy's First Dictionary
- 10815 - Andy's First Dictionary
- 10815 - Andy's First Dictionary
- 10815 - Andy's First Dictionary
- 10815 - Andy's First Dictionary
- 10815 - Andy's First Dictionary
- 10815 - Andy's First Dictionary
- 10815 - Andy's First Dictionary
- Andy's First Dictionary
- Andy's First Dictionary
- Andy's First Dictionary
- Andy's First Dictionary
- Andy's First Dictionary
- Andy's First Dictionary
- Andy's First Dictionary
- 第三十四课 二维数组的存储 【项目1-3】
- date获取年月日
- 设计模式之装饰模式
- mysql数据库---批处理与大文本/图片类型
- 服务器基础 tomcat端口被占用问题的解决
- 10815 - Andy's First Dictionary
- HDU2059 多段决策
- Eclipse将引用了第三方jar包的Java项目打包成jar文件的两种方法
- web基础 Web.xml配置详解
- apt-get update与ssh server服务安装
- controller配置汇总
- Android studio使用问题收录
- [数据结构]链表的基本操作
- iOS开发网络篇—网络编程基础