水果
来源:互联网 发布:win7桌面不显示网络 编辑:程序博客网 时间:2024/04/25 02:35
水果
Time Limit: 2000/1000 MS(Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6667 Accepted Submission(s): 2613
Problem Description
夏天来了~~好开心啊,呵呵,好多好多水果~~
Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想要一份水果销售情况的明细表,这样Joe就可以很容易掌握所有水果的销售情况了.
Input
第一行正整数N(0<N<=10)表示有N组测试数据.
每组测试数据的第一行是一个整数M(0<M<=100),表示工有M次成功的交易.其后有M行数据,每行表示一次交易,由水果名称(小写字母组成,长度不超过80),水果产地(小写字母组成,长度不超过80)和交易的水果数目(正整数,不超过100)组成.
Output
对于每一组测试数据,请你输出一份排版格式正确(请分析样本输出)的水果销售情况明细表.这份明细表包括所有水果的产地,名称和销售数目的信息.水果先按产地分类,产地按字母顺序排列;同一产地的水果按照名称排序,名称按字母顺序排序.
两组测试数据之间有一个空行.最后一组测试数据之后没有空行.
Sample Input
1
5
apple shandong 3
pineapple guangdong 1
sugarcane guangdong 1
pineapple guangdong 3
pineapple guangdong 1
Sample Output
guangdong
|----pineapple(5)
|----sugarcane(1)
shandong
|----apple(3)
这道题我是用结构体和map做的,用到了两个map,map<string,map<string,int> >s;与 map<string,int>s1;这样把地点,名字,和数量三者的关系联系起来了。
#include<iostream>#include<cstring>#include<map>#include<cstdio>using namespace std;struct node{ char name[81],didian[82]; int sum;};int main(){ int n,m,i,j; struct node std[100]; map<string,map<string,int> >s; map<string,int>s1; scanf("%d",&n); while(n--) { scanf("%d",&m); getchar(); for(i=0; i<m; i++) { cin>>std[i].name>>std[i].didian>>std[i].sum; s[std[i].didian][std[i].name]+=std[i].sum; } map<string,int>::iterator it; map<string,map<string,int> >::iterator itt; for(itt=s.begin(); itt!=s.end(); itt++) { cout<<itt->first<<endl; for (it=s[itt->first].begin(); it!=s[itt->first].end(); it++) { printf(" |----"); cout<<it->first<<"("<<it->second<<")"<<endl; } s1.clear(); } s.clear(); if(n>0) printf("\n"); } return 0;}
- 水果
- 水果
- 水果
- 水果
- 水果
- 水果
- 水果
- 水果水果我爱你。。
- 水果单词
- 上水果
- 水果保健
- HOJ1263 水果
- 1040水果
- 水果表达方式
- 水果疗效
- 水果哥
- HDU1263:水果
- 葡萄(水果)
- ,升级ubuntu时,出现您的 python 安装错误,请修复“/usr/bin/python”符号链接。
- java语言中为什么需要集合框架这种技术?
- msec soa
- pbuffer 和fbo的差异
- Laravel 路由
- 水果
- 杭电oj(Java版)—— 2010 水仙花数
- 复习
- XZ_iOS之"User-facing text should use localized string macro”警告的解决
- 使用筛选法得出1~n之间素数
- Unity开发之 UGUI手游界面返回上一层
- Using kernel principal component analysis for nonlinear mappings
- LeetCode 8 8. String to Integer (atoi)
- 计算2个GPS坐标的距离