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. keras对图像数据进行增强 | keras data augmentation

    本文首发于个人博客https://kezunlin.me/post/8db507ff/,欢迎阅读最新内容! keras data augmentation Guide code # import th ...

  2. 【linux】linux命令--uptime查看机器存活多久和平均负载 解读平均负载含义

    一.uptime命令,查看机器存活时间和平均负载 键入命令: uptime 该结果和 top命令查看结果最上面一行的 是一样的显示. 返回数据介绍: #当前服务器时间: 19:56:44 #当前服务器 ...

  3. 基础查询-SQL和Linq相互化

    目录 SELECT SQL SELECT DISTINCT 语句 WHERE 和 操作符 BETWEEN 和操作符 LIKE 和通配符 ORDER BY 排序 TOP In Alias(as) EXI ...

  4. 【2019年版】如何向SAP公司提交Message?

    [2019年版]如何向SAP公司提交Message? 1,浏览器里输入如下网址: ,出现如下界面, 2,点击 'Visit the SAP Support Portal' 按钮.进入如下界面,去菜单M ...

  5. UITableViewStyleGrouped 类型 tableView sectionHeader 高度问题

    UITableViewStyleGrouped 类型的 tableView 在适配的时候出现很大的问题.记录一下 按照之前的方法,只需要执行以下的代码就能够很好的解决 section == 0 的时候 ...

  6. iOS中的GCD线程

    一.什么是GCD      全称是Grand Central Dispatch ,纯C语言编写,提供非常多强大的函数,是目前苹果官网推荐的多线程开发方法,NSOperation 便是基于GCD的封装 ...

  7. vue组件懒加载

    vue2组件懒加载浅析 一. 什么是懒加载 懒加载也叫延迟加载,即在需要的时候进行加载,随用随载. 二.为什么需要懒加载 在单页应用中,如果没有应用懒加载,运用webpack打包后的文件将会异常的大, ...

  8. VM虚拟机Android安装图形界面

    摘自,转 https://blog.csdn.net/weixin_42633191/article/details/89391188

  9. java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x8E' for column 'name' at row 1

    我的错误案例: ,这个后台插不进去,就姓名那栏的中文编码问题. 遇到这个错误,应该是创建表的时候没有设置好编码,这个错误不用多想,我也试过在更改表那里设置编码,但还是不行,还是有残留 直接drop t ...

  10. /usr/lib/python2.7/subprocess.py", line 1239, in _execute_child

    Traceback (most recent call last):File "/home/eping/bin/repo", line 685, in main(sys.argv[ ...