hdu 1263 水果

来源:互联网 发布:电脑中文编程语言视频 编辑:程序博客网 时间:2024/05/01 11:06
#include <cstdio>#include <iostream>#include <string>#include <map>#include <algorithm>using namespace std;typedef map<string, map<string, int> > mapp;int main(){    int t, n, i, k;    string fruit, place;    mapp a;    mapp::iterator ite;    map<string, int>::iterator jte;    cin>>t;    while(t--){        cin>>n;        for(i=0; i<n; i++){            cin>>fruit>>place>>k;            a[place][fruit] += k;        }        for(ite=a.begin(); ite!=a.end(); ite++){            cout<<ite->first<<endl;            for(jte=(ite->second).begin(); jte!=(ite->second).end(); jte++){                cout<<"   |----"<<jte->first<<'('<<jte->second<<')'<<endl;            }        }        a.clear();        if(t!=0) cout<<endl;    }    return 0;}

0 0
原创粉丝点击