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();
}*/