C++ map练习

/*************************************************************************
    > File Name: main1112.cpp
    > Author:keson
    > Mail:[email protected]
    > Created Time: 2014年10月31日 星期五 21时11分10秒
 ************************************************************************/

#include<iostream>
using namespace std;
#include<vector>
#include<utility>
#include<map>
#include<string>
map<vector<string>,vector<pair<string,int>>> m;
vector<pair<string,int>> vec1;
vector<string> s1;
pair<string,int> process()
{
    cout<<"Enter the string and size:"<<endl;
    string v1;
    int v2;
    cin>>v1>>v2;
    return {v1,v2};
}

int main()
{
    cout<<"enter the size of the vector: "<<endl;
    int num;
    cin>>num;
    for(int i=0;i!=num;++i)
    {
        pair<string,int> w=process();
        vec1.push_back(w);
    }
    for(int i=0;i!=num;++i)
    {
        cout<<"Enter the familyname:"<<endl;
        string word;
        cin>>word;
        s1.push_back(word);
    }
    m.insert(make_pair(s1,vec1));
    cout<<m.size()<<endl;

    for(auto &c:m)
    {
    
        auto iter1=c.first.begin();
        auto iter2=c.second.begin();
        for(int i=0;i!=c.first.size();++i)
        {
        cout<<*iter1<<"  "<<(*iter2).first<<" "<<(*iter2).second<<endl;
        ++iter1;
        ++iter2;
        }
    }
    return 0;
    
}

你可能感兴趣的:(C++,map)