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. 【maven】【idea】使用idea的maven进行deploy操作失败,报错:Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project proengine-db-sdk: Failed to deploy artifacts 错误码401

    使用idea的maven进行deploy操作失败,报错: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:- f ...

  2. Spring Security 教程 大牛的教程

    https://www.iteye.com/blog/elim-2247073 Spring Security 教程 Spring Security(20)——整合Cas Spring Securit ...

  3. 网站的favicon图标

    网站的favicon图标 favicon.ico一般用于作为缩略的网站标志,它显示在浏览器的地址栏或者标签上. 制作favicon图标 把图片转换为png图片 把png图片转换为ico图标,这需要借助 ...

  4. 从高版本的 SQL Server 向低版本的 SQL Server 转移数据

    1.在源数据库上右键任务,选择生成脚本- 2.在生成脚本的高级选项中,根据数据库的内容,选择相应的选项,主要是红框圈出的部分,最后选择仅架构(若数据库的数据量不大,可以直接导出 架构和数据,在新数据库 ...

  5. iOS 应用程序启动时要做什么

    当您的应用程序启动(无论是在前台或后台),使用您的应用程序委托application:willFinishLaunchingWithOptions:和application:didFinishLaun ...

  6. hadoop mapreduce求解有序TopN(高效模式)

    1.在map阶段对数据先求解改分片的topN,到reduce阶段再合并求解一次,求解过程利用TreeMap的排序特性,不用自己写算法. 2.样板数据,类似如下 1 13682846555 192.16 ...

  7. USB通信协议深入理解

    0. 基本概念 一个[传输](控制.批量.中断.等时):由多个[事务]组成: 一个[事务](IN.OUT.SETUP):由一多个[Packet]组成. USB数据在[主机软件]与[USB设备特定的端点 ...

  8. 密度峰值聚类算法MATLAB程序

    密度峰值聚类算法MATLAB程序 凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 密度峰值聚类算法简介见:[转] 密度峰值聚类算法(DPC) 数据见:MATL ...

  9. luoguP3531 [POI2012]LIT-Letters

    (https://www.luogu.org/problem/P3531) 注意编号 #include<cstdio> #include<algorithm> #include ...

  10. Maven中使用tomcat:run出现错误org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException

    配置是正常的.查阅资料以后说是jdk版本什么的问题.多方修改没有任何改观.换一个思路去查询tomcat:run怎么运行. 是因为他还是沿用了上一次的tomcat插件(默认是6)所以运行的时候使用 to ...