Andy's First Divtionary id:10815
来源:互联网 发布:唐凤 知乎 编辑:程序博客网 时间:2024/05/16 17:51
分析:
题目本身很简单,关键是利用STL中的set,即可轻松解决该问题。
set即集合,其中不允许有重复的元素存在
常见的set操作如下:(set<int> s)
插入元素:s.insert(15)
删除元素:s.erase(15)或者s.clear()
查找元素:s.find(15)
这三个只是最基本的操作,注意查找元素时返回的是迭代器的位置,如果集合中没有该元素,则返回集合最后一位后面的位置。
AC代码如下,基本照搬RuJia:
#include <iostream>#include <set>#include <string>#include <sstream>using namespace std;set<string> words;int main(){ string str, s; while(cin >> str) { for(int i = 0; i < str.length(); i++) if(isalpha(str[i])) str[i] = tolower(str[i]); else str[i] = ' '; stringstream ss(str); while(ss >> s) words.insert(s); } for(set<string> :: iterator it = words.begin(); it != words.end(); it++) cout << * it << "\n"; return 0;}
0 0
- Andy's First Divtionary id:10815
- 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
- UVa OJ 10815-Andy's First Dictionary
- uva 10815 Andy's First Dictionary
- UVa 10815 - Andy's First Dictionary
- 10815 - Andy's First Dictionary未通过
- UVA 10815 - Andy's First Dictionary
- uva-10815 - Andy's First Dictionary
- corethink功能模块探索开发(五)开启这个模块的配置
- java中的List
- 在bitnami集成环境下进行redmine的二次开发--开发环境的搭建
- win10任务栏点击右键无反应解决方法
- 我的ios 开发学习之旅!
- Andy's First Divtionary id:10815
- problem-1006 Elevator 解题报告
- 对位平面和帧缓存的理解(转载)
- 主题模型-LDA浅析
- hdu3001(状态压缩dp,三进制!)
- 计算几何--判断线段是否相交
- Windows CMD
- notes 拍照显示
- C# 的时间戳转换