题意:给定水果交易记录,按要求格式输出即可
题解:
用STL中的MAP
简单模拟;
为水果的产地和名字创建一个类, 这样水果就是唯一的, 然后映射这个水果的数量, 按要求输出即可;
//code
#include<iostream>
#include<map>
#include<cstring>
#include<cstdio>
using namespace std;
struct Fruit{
char name[100];
char from[100];
friend bool operator == (Fruit a, Fruit b)
{
if(strcmp(a.name, b.name) == 0 && strcmp(a.from, b.from) == 0) return true;
else return false;
}
friend bool operator < (Fruit a, Fruit b)
{
if(strcmp(a.from, b.from) == 0)
{
if(strcmp(a.name, b.name) == -1) return true;
else return false;
}
else if(strcmp(a.from, b.from) == -1) return true;
else return false;
}
};
int main()
{
int Case;
scanf("%d", &Case);
w