1. Vector动态数组
工具:
#include<vector>
#include<iostream>
using namespace std;
int main()
{
vector<int>v1; // 此为创造一个一维动态数组
v1.push_back(1); // 此为在末尾加入一个元素
v1.pop_back(); // 此为在末尾弹出一个元素
cout<<v1.size()<<endl; // 此为获取动态数组的长度
vector<int>v2[20]; //此为创造一个二维动态数组
vector<vector<int> >vec2(n,vector<int>(m,0)); //此为创建两个维度均为动态数组的数组,初始化为0
}
2.Set集合
工具:
#include<iosteram>
#include<set>
#include<string>
using namespace std;
int main()
{
// 注意set会将插入的元素从小到大排列
set<string>country;
country.insert("France"); //向其中插入一个元素,如果这个元素已经存在,则不插入
country.erase("China"); //如果这个元素存在,则将其删除
if(country.count("France") ) //如果这个元素存在,则返回true
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
set<string>::iterator : it; //这样可以完成一次对set元素的遍历
for(it=country.begin();it!=country.end();it++)
cout<<*it<<endl;
cout<<country.size()<<endl //显示country元素的个数
}
3.Map映射
工具:
参考这个;