UVA 10815 Andy's First Dictionary(stl,set)
来源:互联网 发布:饥荒mac中文版mod 编辑:程序博客网 时间:2024/05/13 01:18
UVA 10815 Andy’s First Dictionary
题目:给出一串单词,把所有单词改小写去重按字典序输出。
思路:set可以解决去重和排序问题。(这点很关键,从小到大排序)
set中每个元素最多只出现一次
如何通过迭代器从小到大遍历所有元素
for (set::iterator i = d.begin(); i != d.end(); i++)
cout << *i << endl;
#include <iostream>#include <string>#include <set>using namespace std;set<string>jihe;int main(){ string s; while(getline(cin,s)) { string tmp; for(int i=0;i<=s.size();i++) { if(s[i]>='A'&&s[i]<='Z') { s[i]=s[i]+32; tmp+=s[i]; } else if(s[i]>='a'&&s[i]<='z') { tmp+=s[i]; } else { if(!tmp.empty()) { jihe.insert(tmp); tmp.clear(); } } } if(!tmp.empty()) jihe.insert(tmp); } for(set<string>::iterator it=jihe.begin();it!=jihe.end();it++) { cout<<*it<<endl; } return 0;}/*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.*/
0 0
- UVA 10815 Andy's First Dictionary(stl,set)
- UVa - 10815 - Andy's First Dictionary(STL - 集合set)
- UVa 10815 Andy's First Dictionary 【STL】【set】
- uva-10815-Andy's First Dictionary-stl-set
- UVA 10815 Andy's First Dictionary(STL)
- UVa - 10815 Andy's First Dictionary(STL)
- UVA 10815-Andy's First Dictionary(字符串模拟+排序+重复删除||STL-set)
- Andy's First Dictionary(uva 10815) set用法
- UVA 10815 Andy's First Dictionary(stringstream,set等)
- UVA 10815 Andy's First Dictionary(set的应用)
- UVA 10815 Andy's First Dictionary 安迪的字典 stl应用 set+string做法
- UVa-10815-Andy's First Dictionary c++ STL set 基础练习题
- Set操作UVa 10815Andy's First Dictionary
- UVa 10815 Andy's First Dictionary 【set】【字典序】
- uva 10815 Andy's First Dictionary stl 函数
- Andy's First Dictionary(set)
- 集合set练习:Andy's First Dictionary(UVa 10815)代码
- 紫书章5例三 Andy's First Dictionary, UVA 10815(set)
- 笨方法学Python中习题5 在Python3
- Objective-C NSObject
- 除法取模逆元,扩展欧几里得,费马小定理[数学]
- 【Spring框架】Spring AOP 回忆总结
- Mybatis-SQL执行流程分析
- UVA 10815 Andy's First Dictionary(stl,set)
- Visual Studio 2015中ucrtbased.dll丢失
- latex学习总结
- UML之状态图
- DOM遍历
- Python(7):numpy初步
- logstsha 发送数据到数据节点
- rxvolley实现常用快递查询
- ClassNotFoundException: org.springframework.scheduling.quartz.CronTriggerBean