Map的嵌套,HDU(1263)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1263

新学的map的嵌套

#include <stdio.h>
#include <map>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int order;
        scanf("%d",&order);

        map<string,map<string,int> > maps;

        string name,place;
        int num;

        while(order--)
        {
            cin>>name>>place>>num;
            maps[place][name]+=num;
        }

        map<string,map<string,int>,> ::iterator pos;

        for(pos=maps.begin();pos!=maps.end();pos++)
        {
            cout<<pos->first<<endl;
            map<string,int> ::iterator pos2;

            for(pos2=pos->second.begin();pos2!=pos->second.end();pos2++)
            {
                cout<<"   |----"<<pos2->first<<"("<<pos2->second<<")"<<endl;
            }

        }
        if(t)
            cout<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/TreeDream/p/5705426.html