1028. List Sorting_结构体排序
来源:互联网 发布:弱视训练软件 编辑:程序博客网 时间:2024/06/06 18:31
http://pat.zju.edu.cn/contests/pat-a-practise/1028
简单的结构体排序
#include<stdio.h>#include<algorithm>#include<string.h>using namespace std;struct E{char num[10];char name[10];int score; }buf[100010];bool cmp1(E a,E b){return strcmp(a.num,b.num) < 0; }bool cmp2(E a,E b){int temp=strcmp(a.name,b.name); if(temp!=0)return temp<0;else return strcmp(a.num,b.num) < 0; }bool cmp3(E a,E b){ if(a.score!=b.score) return a.score < b.score;elsereturn strcmp(a.num,b.num) < 0; }int main(){ freopen("D:\\test.txt","r",stdin);int n,c,i;while(scanf("%d%d",&n,&c)!=EOF && (n!=0)){for(i=0;i<n;i++){scanf("%s%s%d",buf[i].num,buf[i].name,&buf[i].score);}if(c==1){sort(buf,buf+n,cmp1);}else if(c==2){sort(buf,buf+n,cmp2);}else if(c==3){sort(buf,buf+n,cmp3);}for (i=0;i<n;i++){printf("%s %s %d\n",buf[i].num,buf[i].name,buf[i].score);}}return 0;}
- 1028. List Sorting_结构体排序
- POJ1007_DNA Sorting_归并排序求逆序对
- list 中的结构体排序
- PAT (Advanced Level) 1028. List Sorting (25) 结构体排序
- zoj2727-------------------List the Books 结构体排序
- STL中list结构体元素排序
- 1083. List Grades (25)[结构体排序]
- STL的list容器如何对结构体进行排序
- list结构体根据某个成员进行排序
- STL list查找、删除、结构体实例化对象排序
- PAT (Advanced Level) 1083. List Grades (25) 结构体排序
- STL list(链表)自定义结构体实现排序
- HDU_2838_Cow Sorting_树状数组
- STL-有关list元素为结构体,而按其中一元素排序问题
- list元素为结构体,而按其中一元素排序问题
- PAT (Advanced Level) 1052. Linked List Sorting (25) 结构体排序
- 结构体排序,多级排序
- List 类存储结构体
- LXC LinuX Containers
- JS截取字符串:slice(),substring()和substr()
- opencv最简单的显示程序
- 用vs2008创建运行c++项目
- SQLServer With(NoLock)
- 1028. List Sorting_结构体排序
- 基于图像分块的图像分割
- Linux开发经验锦集(一)
- 再次打包IE64 可以使用的cab文件,关于inf文件写法和IE自动解压失败的解决过程
- 使用SSH Agent Forwarding
- ORA-01000: 超出打开游标的最大数 问题的分析和解决
- Java中读取属性文件以及做资源国际化
- hive 简单执行完的数据和join完的数据插入到hbase执行结果
- 谈谈Android中WIFI 架构和控制流程