九度1023
来源:互联网 发布:狗镇 知乎 编辑:程序博客网 时间:2024/06/02 06:56
#include<stdlib.h>#include<stdio.h>#include<string>#include<cstring>#include<algorithm>#include<math.h>using namespace std;typedef struct{ char name[20],num[20]; int mark;}student;bool cmp1(student a,student b){ int temp=strcmp(a.num,b.num); if(temp!=0) { return temp<0; }}bool cmp2(student a,student b){ int temp=strcmp(a.name,b.name); if(temp!=0) { return temp<0; } else { int temp2=strcmp(a.num,b.num); if(temp2!=0) { return temp2<0; } }}bool cmp3(student a,student b){ if(a.mark!=b.mark) { return a.mark<b.mark; } else { int temp2=strcmp(a.num,b.num); if(temp2!=0) { return temp2<0; } }}int main(){ int n,c,count=0,i; while(scanf("%d %d",&n,&c)!=EOF&&n!=0&&c!=0) { count++; student stu[n]; for(i=0;i<n;i++) { scanf("%s %s %d",&stu[i].num,&stu[i].name,&stu[i].mark); } if(c==1) { sort(stu,stu+n,cmp1); } else if(c==2) { sort(stu,stu+n,cmp2); } else if(c==3) { sort(stu,stu+n,cmp3); } printf("Case %d:\n",count); for(i=0;i<n;i++) { printf("%s %s %d\n",stu[i].num,stu[i].name,stu[i].mark); } } return 0;}
0 0
- 九度1023
- 九度 oj 1023
- 九度题目1023
- 九度OJ 1023
- 九度1023
- 九度1023 EXCEL排序
- 九度-1023-EXCEL排序
- 九度1023:EXCEL排序
- 九度1023 EXCEL排序
- 九度OnlineJudge之1023:EXCEL排序
- 【九度】题目1023:EXCEL排序
- 九度题目1023:EXCEL排序
- 【九度OJ】1023【希尔排序】
- 九度OJ题目1023:EXCLE排序
- 九度OJ 题目1023:EXCEL排序
- 九度OJ 题目1023:EXCEL排序
- 九度-题目1023:EXCEL排序
- 【九度】题目1023:EXCEL排序
- 【IOS学习】CocoaPods安装使用及配置私有库
- CSDN 博客文章误删到回收站 恢复
- UVa 397 - Equation Elation
- 最详细的 NavigationDrawer 开发实践总结(上)
- 通过rosjava实现android订阅ROS自定义消息
- 九度1023
- Android开源项目大全 - 视图View类
- 51Nod 1344 走格子
- vp9 命令行参数
- 详解 CSS 属性 - 伪类和伪元素的区别
- 1005 Number Sequence
- 项目发布: error CS0103: 当前上下文中不存在名称“*****”
- 最详细的 NavigationDrawer 开发实践总结(下)
- 多表连接一