#include<iostream>
#include<string>
#include<cstring>
#include<map>
using namespace std;
unordered_map<int,int> mp;
typedef struct tagStudentinfo{
int niD;
string strName;
}Studentinfo, *PStudentinfo; //学生信息
class sorted{
public:
bool operator() (Studentinfo const &_A, Studentinfo const &_B) const {
if(_A.niD < _B.niD)
return true;
if(_A.niD == _B.niD)
return _A.strName.compare(_B.strName) < 0;
return false;
}
};
map<Studentinfo, int, sorted>mapStudent;
/******************************/
typedef struct ip_tuple
{
int src_port;
int dst_port;
char* src_ip;
bool operator <(const ip_tuple& other) const
{
if (src_port < other.src_port) //src_port按升序排序
{
return true;
}
else if (src_port == other.src_port) //src_port相同,按dst_port升序排序
{
if(dst_port < other.dst_port)
{
return true;
}
else if(dst_port == other.dst_port)//dst_port,src_port相同,比较src_ip
{
if(strcmp(src_ip,other.src_ip)!=0)
{
return true;
}
}
}
return false;
}
} IPTUPLE;
map<IPTUPLE, int>m_roadMap;
/*********************************/
int main()
{
int T;
cin>>T;
while(T--)
{
string fruit,place;
int num,n;
cin>>n;
map<string,map<string,int> >a;
map<string,map<string,int> >::iterator p;
while(n--){
cin>>fruit>>place>>num;
a[place][fruit]+=num;
}
for(p=a.begin();p!=a.end();p++){
cout<<p->first<<endl;
map<string,int>::iterator p1;
for(p1=p->second.begin();p1!=p->second.end();p1++)
cout<<" |----"<<p1->first<<"("<<p1->second<<")"<<endl;
}
if(T) cout<<endl;
}
return 0;
}
https://www.cnblogs.com/fnlingnzb-learner/p/5833051.html