hdu 1263 水果 sort对结构体中字符串二级排序

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
struct node
{
char name[90],place[90];
int num;
}c[105];
bool cmp(node x,node y)
{
if(strcmp(x.place,y.place)<0) return true;
if(strcmp(x.place,y.place)==0&&strcmp(x.name,y.name)<0) return true;
return false;
}
int main()
{
int test,n;
scanf("%d",&test);
while(test–)
{
memset(&c,0,sizeof(&c));
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%s %s %d",c[i].name,c[i].place,&c[i].num);
sort(c,c+n,cmp);
for(int i=0;i<n;i++){
if(strcmp(c[i].place,c[i+1].place)==0)
{
if(strcmp(c[i].name,c[i+1].name)==0)
c[i+1].num+=c[i].num,c[i].num=0;
}
else
{
printf("%s
",c[i].place);
for(int j=0;j<n;j++)
{
if(strcmp(c[i].place,c[j].place)==0&&c[j].num)
printf(" |—-%s(%d)
",c[j].name,c[j].num);
}
}

}
if(test!=0)
printf("
");
}
return 0;
}

波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » hdu 1263 水果 sort对结构体中字符串二级排序

44 评论

  1. order sporanox for sale tinidazole cost purchase tinidazole for sale

  2. norvasc usa viagra 50mg uk buy cialis 20mg online cheap

  3. order sildenafil 50mg pill viagra 50mg cost generic tadalafil 40mg

  4. order furosemide 100mg online cost furosemide hydroxychloroquine tablet

  5. purchase asacol for sale irbesartan 300mg us irbesartan 150mg over the counter

  6. oral pepcid 20mg pepcid us order remeron

  7. tadalafil without prescription Cialis store order generic sildenafil 50mg

  8. tadalafil uk cialis canada best ed pill for diabetics

  9. buy deltasone 20mg generic buy accutane amoxicillin 250mg us

  10. buy albuterol online cheap synthroid order generic augmentin

  11. order generic doxycycline 200mg levitra 10mg drug acyclovir 800mg ca

发表评论

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡