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)

爱上结构体了!!!!!!

注意输出格式就行了!!!!!!

代码:

#include <iostream>
#include <cstring>
#include <string>
#include <iomanip>
#include <algorithm>
using namespace std; struct dot
{
string s,t;
int n;
}st[1000];
int cmp(dot x,dot y)
{
if(x.t!=y.t)
return x.t<y.t;
else
return x.s<y.s;
}
int main()
{ int i,j,k,m,T;
cin>>T;
k=0;
while(T--)
{cin>>m;
for(i=0;i<m;i++)
cin>>st[i].s>>st[i].t>>st[i].n;
sort(st,st+m,cmp); for(i=m-1;i>0;i--)
{
if(st[i].s==st[i-1].s&&st[i].t==st[i-1].t)
st[i-1].n+=st[i].n;
}
if(k)cout<<endl;
cout<<st[0].t<<endl<<" |----"<<st[0].s<<"("<<st[0].n<<")"<<endl;
for(i=1;i<m;i++)
{ if(st[i].t==st[i-1].t&&st[i].s!=st[i-1].s)
cout<<" |----"<<st[i].s<<"("<<st[i].n<<")"<<endl;
else if(st[i].t!=st[i-1].t)
cout<<st[i].t<<endl<<" |----"<<st[i].s<<"("<<st[i].n<<")"<<endl;
} k++;
}
return 0;
}

hdu 1263 水果的更多相关文章

  1. hdu 1263 水果 【二维map】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1263 题目大意: Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ ...

  2. 题解报告:hdu 1263 水果

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1263 Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ Joe经营 ...

  3. HDU 1263(水果统计 **)

    题意是对水果的产地和种类进行统计再按格式输出. 代码如下: #include <bits/stdc++.h> using namespace std; struct node { ],pl ...

  4. hdu 1263 水果 结构的排序+sort自定义排序

    水果 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  5. HDU 1263 水果 结构体排序

    解题报告:一个结构体排序的题,用了一个运算符重载,要注意的是不同的地方可能会产相同的水果,一开始没注意. #include<cstdio> #include<cstring> ...

  6. hdu 1263 水果 (嵌套 map)

    水果Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissio ...

  7. HDU 1263 水果 (STL map)

    水果 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  8. STL || HDU 1263 水果

    map可以映射map…… 然后在map里面会自己排序 惊了 注意输出格式 回车的输出 #include <iostream> #include <cstdio> #includ ...

  9. ACM 水果 hdu 1263 一题多解

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1263 文章末有相应的一些测试数据供参考. 传统的数组解题方式 思路一: 三种属性的数据放在一个结构体里面, ...

随机推荐

  1. js formatString 格式化字符串

    /* 函数:格式化字符串 参数:str:字符串模板: data:数据 调用方式:formatString("api/values/{id}/{name}",{id:101,name ...

  2. var foo= {} ;foo.method() 和 单例模式有什么区别

    var Foo={} Foo.method = function() { var i = 0; return { a:function(){ console.log('aa', i++); }, b: ...

  3. phpword的几个坑

    下载地址http://phpword.codeplex.com/ 开发目的:有现成的word模板 替换模板中的字段 1.中文乱码问题,如果你文件本身就是utf8...把Phpword里的模板类的一行转 ...

  4. ECSTORE 货币格式

    世界上许多国家都有不同的货币 格局和数字 格局 特例 .针对特定的当地化环境正确地 格局化和显示货币是当地化的一个主要部分,ecstore 可以同过后台的设置,来更改货币的格式,具体方式为 后台-&g ...

  5. ECSTORE 新建APP应用

    1.用命令新建app // ----- window平台 ----- 直接运行 " 站点根目录/app/base/cmd.bat " 出现命令行后输入 dev:new app my ...

  6. 搭建Nuget

    1.  新建一个 ASP.NET 空Web应用程序 2. 在新建的项目中引用 安装 NuGet.Server 2.1 右键项目中的引用,出现一个“管理NuGet程序包(N)”,点击进入 2.2  在搜 ...

  7. Hadoop学习历程(一、编译)

    近期对Hadoop很感兴趣,下面是在CentOS系统上进行编译的分享 系统情况如下: 1. CentOS 6.2 64位    2. hadoop-2.2.0    3. jdk 1.6.0_31   ...

  8. 《VIM-Adventures攻略》 LEVEL 1-3

    此文已转至http://cn.abnerchou.me/2014/03/04/e40e2146/ 上期有人提到此游戏烂尾.其实没有啦,作者是位"贪财"的主,不付费不给玩剩下的章节. ...

  9. LeetCode_Generate Parentheses

    Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes ...

  10. elasticsearch 修改内存

    [elk@zjtest7-redis bin]$ cat elasticsearch.in.sh if [ "x$ES_MIN_MEM" = "x" ]; th ...