7.14自学总结有关STL--Sabrina

vector
添加头文件#indlude
vector a[1000];每个a[]是一个vector
a[1].push_back()向尾部添加
a[1].pop_back()删除最后一个
a[1].size()读取大小
a[1].resize(h+1)改变数组大小为0到h
a[1].clear()清除所有
cout<<a[1][0]
是一个不定长数组
set
set a;int集合
a.begin()第一个元素
a.end()最后一个元素
for(set::iterator it=a.begin();it!=a.end();++it)
cout<<*it;
iterator :迭代器``
isalpha:判断字符ch是否为英文字母,isalpha(ch)
若为英文字母,返回非0(小写字母为2,大写字母为1),若不是字母返回0
tolower:讲字母字符转换成小写,非字母字符不做处理
map
{
从键到值的映射
map<string,int>month_name就表示月份名字到月份编号的映射
然后用 month_name[“July”]=7;
}

栈(stack):
{
stack s
后进先出
s.push
push将元素压入栈顶
pop将元素从栈顶弹出
top取栈顶元素
#include
stacks//声明一个栈
}
优先队列
priority_ququepp
pp是一个越小的整数优先级越低的队列
pp.top()输出最大数
pp.pop()删除最大数
pp.empty()如果队列为空返回true
pp.push(1)添加

#include<cstdio>
#include<iostream>
//#include<vector>
//#include<stack>
#include<queue>
using namespace std;
priority_queue<int> s;
int main()
{
	if(s.empty()) cout<<"sabrina1"<<endl;
	s.push(1);

	s.push(32);	s.push(2);
	if(s.empty()) cout<<"sabrina"<<endl;
	s.pop();
		cout<<s.top();
	
	
}
/*stack<int> s;
int main()
{
	s.push(1);
	cout<<s.top()<<endl;
	s.push(2);
	s.push(3);
	s.pop();
	cout<<s.top();
	return 0;
}
/*vector<int> a;
int main()
{
	a.push_back(1);
	cout<<a[0];
	a.clear();
}*/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值