标签:
1 #include<iostream> 2 #include<map> 3 #include<string> 4 using namespace std; 5 int main() 6 { 7 int T; 8 cin>>T; 9 while(T--){ 10 int n; 11 string fruit; 12 string add; 13 int num; 14 cin>>n; 15 map<string,map<string,int> >m; 16 while(n--){ 17 cin>>fruit>>add>>num; 18 (m[add])[fruit] += num; 19 } 20 map<string,map<string,int> >::iterator key; 21 for(key = m.begin();key!=m.end();key++){ 22 cout<<key->first<<endl; 23 map<string,int>::iterator i= (key->second).begin(); 24 for(;i!=(key->second).end();i++) 25 cout<<" |----"<<i->first<<"("<<i->second<<")"<<endl; 26 } 27 if(T>0){ 28 cout<<endl; 29 } 30 } 31 }
标签:
原文地址:http://www.cnblogs.com/blueprintf/p/4704452.html