unorder_map<int,vector<int>>使用

#include 
#include 
#include 
#include 
#include 
using namespace std;

int main()

{
vector>v;
vectorv1;
vectorv2;
vectorv3;

for(int i =0;i<3;i++)

{
v1.push_back(i);
v2.push_back(i+1);
v3.push_back(i+2);
}

cout << endl;

v.push_back(v1);
v.push_back(v2);
v.push_back(v3);

for(vector>::iterator it = v.begin();it != v.end();it++)
{
for(vector::iterator vit = (*it).begin();vit != (*it).end();vit++)
{
cout << *vit << " ";
}
cout << endl;
}
cout << endl;
unordered_map >umap;
umap.emplace(1,v1);
cout << umap.size() << endl;
vectorw;
for(auto it = umap[1].begin();it!= umap[1].end();it++)
{
w.push_back(*it) ;
}

for(auto itr = w.begin();itr!=w.end();itr++)
{
cout << *itr << " ";
}
cout << endl;

for(unordered_map>::iterator ptr = umap.begin();ptr!= umap.end();ptr++)

{
cout << ptr->first << ":";
for(vector::iterator it1 = ptr->second.begin();it1!=ptr->second.end();it1++)
{
cout << *it1 << " ";
}
cout << endl;
}
}

你可能感兴趣的:(C++,c++,算法,开发语言)