[STL] UVA 10815 安迪的第一个字典 Andy's First Dictionary
1、set
集合 哦....对了,set有自动按照字典序排序功能。。。。。
声明和插入操作
#include <cstdio>
#include <vector>
#include <set>
using namespace std;
int main(){
vector<int> v;
for (int i = ; i < ; i++)
{
v.push_back(i);
v.push_back(i);
}
set<int> s;
s.insert(v.begin(), v.end());
//因为是集合,所以重复的元素不会被重复插入
for (set<int>::iterator it = s.begin(); it != s.end(); it++)
printf("%d\n", *it);
printf("\n");
return ;
}
删除操作
这个一般都用的是erase()--->删除指定的元素或者删除指定部分的元素 和 clear()--->清除所有元素 操作如下:
set<int> s;
s.erase();
s.clear();
查找操作
set支持upper_bound() lower_bound() find()等操作 举个例子:
set<int> s;
set<int>::iterator it;
it = s.find(); //查找键值为5的元素
if (it != s.end()) //找到了
cout << *it << endl;
2、isalpha()
判断字符ch是否为英文字母,若为英文字母,返回非0(小写字母为2,大写字母为1)。若不是字母,返回0。 具体用法见下
3、stringstream()
输入输出转换操作 具体用法见下
4、tolower()
是一种函数,功能是把字母字符转换成小写,非字母字符不做出处理。 具体用法见下
下面是该题代码:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<sstream>
#include<set>
using namespace std;
set<string>aa;
string s,cur;
int main(){
std::ios::sync_with_stdio(false);
while(cin>>s)
{
for(int i=0;i<s.length();i++)
{
if(isalpha(s[i])) s[i]=tolower(s[i]);
else s[i]=' ';
}
stringstream ss(s);
while(ss>>cur)
aa.insert(cur);
}
for(set<string>::iterator it=aa.begin();it!=aa.end();it++)
{
cout<<*it<<endl;
}
return 0;
}
[STL] UVA 10815 安迪的第一个字典 Andy's First Dictionary的更多相关文章
- UVa 10815 安迪的第一个字典
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- STL语法——集合:set 安迪的第一个字典(Andy's First Dictionary,UVa 10815)
Description Andy, , has a dream - he wants to produce his very own dictionary. This is not an easy t ...
- 安迪的第一个字典(Andy's First Dictionary,UVa 10815)
Description Andy, , has a dream - he wants to produce his very own dictionary. This is not an easy t ...
- 安迪的第一个字典(Andy's First Dictionary,Uva 10815)
输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出.单 词不区分大小写. 样例输入: Adventures in Disneyland Two blondes were goin ...
- set的运用 例题5-3 安迪的第一个字典(Andy's First Dictionary,Uva 10815)
#include<bits/stdc++.h>using namespace std;set<string> dict;int main(){ string s, buf; w ...
- stl的集合set——安迪的第一个字典(摘)
set就是数学上的集合——每个元素最多只出现一次,和sort一样,自定义类型也可以构造set,但同样必须定义“小于”运算符 以下代码测试set中无重复元素 #include<iostream&g ...
- 安迪的第一个字典(UVa10815)
题目具体描述见:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_prob ...
- 5_3 安迪的第一个字典(UVa10815)<set的使用>
Andy 是个 8 岁的孩子,他梦想要制作一本他自己的字典. 这并不是一件容易的事,因为他认识的字还不是那么多. 他并不想要自己去想这本字典中该放哪些字,他有个聪明的主意. 就是拿出他最喜欢的一本故事 ...
- 安迪的第一个字典 (Andy's First Dictionary,UVa10815)
题目描述: #include<iostream> #include<string> #include<set> #include<sstream> us ...
随机推荐
- Redisson实现分布式锁(1)---原理
Redisson实现分布式锁(1)---原理 有关Redisson作为实现分布式锁,总的分3大模块来讲. 1.Redisson实现分布式锁原理 2.Redisson实现分布式锁的源码解析 3.Redi ...
- Revit二次开发 屏蔽复制构件产生的重复类型提示窗
做了很久码农,也没个写博客的习惯,这次开始第一次写博客. 这个问题也是折腾了我接近一天时间,网上也没有任何的相关博文,于是决定分享一下,以供同样拥有此问题的小伙伴们参考. 内容源于目前在做的一个项目, ...
- Z从壹开始前后端分离【 .NET Core2.0/3.0 +Vue2.0 】框架之十 || AOP面向切面编程浅解析:简单日志记录 + 服务切面缓存
本文梯子 本文3.0版本文章 代码已上传Github+Gitee,文末有地址 大神反馈: 零.今天完成的深红色部分 一.AOP 之 实现日志记录(服务层) 1.定义服务接口与实现类 2.在API层中添 ...
- kafka集群在消息消费出现无法找到topic分区的处理解决
最近几天在做spark数据同步过程中,中间通过kafka集群处理消息,每次同步到一半就会出现同步不了 查看日志如下: 最开始看到这个问题很懵逼,完全找不到解决问题的切入口,期间也询问了架构师-因为这个 ...
- async/await简单使用
function process(i) { var p = new Promise(function(resolve,reject){ setTimeout(function(){ console.l ...
- js清除定时器注意点
如何这篇文章所述:https://www.cnblogs.com/mmykdbc/p/7418575.html js多次调用创建定时器的函数,会使定时器速度越来越快,多次调用定时器的使用场景比如:监听 ...
- Shodan搜索引擎在信息搜集中的应用
Shodan搜索引擎在信息搜集中的应用 作者:王宇阳 时间:2019-06-07 soudan(搜蛋),通过互联网后的通道来搜索信息:Google通过网址搜索互联网,shodan搜索互联网的在线.指定 ...
- ABP进阶教程11 - 小结
点这里进入ABP进阶教程目录 效果预览 至此,ABP进阶教程的查询/分页/排序/导出/打印示例已完成,效果如下 登录 首页 办公室信息 院系信息 课程信息 教职员信息 学生信息 新增 修改 删除 查询 ...
- Docker 类面试题(常见问题)
Docker 常见问题汇总 镜像相关 1.如何批量清理临时镜像文件? 可以使用sudo docker rmi $(sudo docker images -q -f danging=true)命令 ...
- CSP认证201812
201812-1 #include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f #define ll long l ...