nanke

蛮好的题目,练STL,双重Map

#include<iostream>
#include<map>
#include<string>
using namespace std;
int main()
{
     int a;
     cin>>a;
     while(a--)
     {
         map<string,map<string,int> >m;
         int b,count;
         cin>>b;
         string x,y;
         while(b--)
         {
             cin>>x>>y>>count;
             m[y][x]+=count;
         }

         map<string,map<string,int> > ::iterator it;
         for(it=m.begin();it!=m.end();it++)
         {
             cout<<it->first<<endl;
             map<string,int>::iterator it2;
             for(it2=it->second.begin();it2!=it->second.end();it2++)
                 cout<<"   |----"<<it2->first<<"("<<it2->second<<")"<<endl;
         }
   
         if(a)
             cout<<endl;
      }
     return 0;
}
 

 

分类:

技术点:

相关文章:

  • 2021-12-12
  • 2021-10-29
  • 2021-10-07
  • 2021-11-04
  • 2021-12-12
  • 2021-12-12
  • 2021-10-06
  • 2018-03-01
猜你喜欢
  • 2021-09-01
  • 2018-07-26
  • 2019-06-24
  • 2021-05-25
  • 2021-08-16
  • 2021-12-03
  • 2021-09-28
相关资源
相似解决方案