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的更多相关文章

  1. UVa 10815 安迪的第一个字典

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  2. 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 ...

  3. 安迪的第一个字典(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 ...

  4. 安迪的第一个字典(Andy's First Dictionary,Uva 10815)

    输入一个文本,找出所有不同的单词(连续的字母序列),按字典序从小到大输出.单 词不区分大小写. 样例输入: Adventures in Disneyland Two blondes were goin ...

  5. 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 ...

  6. stl的集合set——安迪的第一个字典(摘)

    set就是数学上的集合——每个元素最多只出现一次,和sort一样,自定义类型也可以构造set,但同样必须定义“小于”运算符 以下代码测试set中无重复元素 #include<iostream&g ...

  7. 安迪的第一个字典(UVa10815)

    题目具体描述见:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_prob ...

  8. 5_3 安迪的第一个字典(UVa10815)<set的使用>

    Andy 是个 8 岁的孩子,他梦想要制作一本他自己的字典. 这并不是一件容易的事,因为他认识的字还不是那么多. 他并不想要自己去想这本字典中该放哪些字,他有个聪明的主意. 就是拿出他最喜欢的一本故事 ...

  9. 安迪的第一个字典 (Andy's First Dictionary,UVa10815)

    题目描述: #include<iostream> #include<string> #include<set> #include<sstream> us ...

随机推荐

  1. PageHelper使用以及PageInfo中分页对象的转化

    在使用Mybatis查询数据库展示到前端的过程中不可避免的要考虑到分页问题,这时就引入了Mybatis的PageHelper插件,这个插件对分页功能进行了强有力的封装,只需要将查询出来的数据List集 ...

  2. IIS 上部署 ASP.NET Core 应用程序

    1.下载 .Net Core Runtime 和 Hosting Bundle 下载地址:https://dotnet.microsoft.com/download/dotnet-core 分别下载 ...

  3. 湖南省web应用软件(中慧杯)

    湖南省web应用软件 写这篇博客已经是比完赛的第四天了,我还记得那天下着小雨.我们早早的到了比赛的现场抽检机器,在比赛前一天我很是激动.我还记得我们从学校,去株洲的时候我们的领导来给我加油,特别是我的 ...

  4. DataGridView中的rows.Count比实际行数多1的原因以及解决办法

    场景 DataGridView怎样实现添加.删除.上移.下移一行: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10281414 ...

  5. SpringBoot源码解析系列文章汇总

    相信我,你会收藏这篇文章的 本篇文章是这段时间撸出来的SpringBoot源码解析系列文章的汇总,当你使用SpringBoot不仅仅满足于基本使用时.或者出去面试被面试官虐了时.或者说想要深入了解一下 ...

  6. 高强度学习训练第十一天总结:Class文件结构(二)

    常量池 可以理解为Class文件之中的资源仓库,他是Class文件结构中与其他项目关联最多的数据类型,也是占用Class文件空间最大的数据项目之一 访问标志 在常量池结束后,紧接着的俩个字节代表访问标 ...

  7. Cesium-空间分析之通视分析(附源码下载)

    Cesium Cesium 是一款面向三维地球和地图的,世界级的JavaScript开源产品.它提供了基于JavaScript语言的开发包,方便用户快速搭建一款零插件的虚拟地球Web应用,并在性能,精 ...

  8. LayoutSubviews的调用

    1.当view被添加到另一个view上时调用 2.布局子控件时调用 3.屏幕旋转的时候调用 4.当view的尺寸大小改变的时候调用

  9. July 13th, 2018. Friday, Week 28th.

    Don't let the mistakes and disappointments of the past control and direct your future. 不要让你的未来被过去的错误 ...

  10. Rust,重温猜猜看

    其实,这个知识点蛮多的, 常看常新. use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { println!("Gu ...