题目1023:EXCEL排序---------Case后面的是count,不是C
#include<stdio.h> #include<algorithm> #include<cstring> using namespace std;struct student {char num[10];char name[10];int grade; }s[100002]; int cmp1(student s1,student s2)//case 1 按照学号递增 {return strcmp(s1.num,s2.num)<0; } int cmp2(student s1,student s2)//case 2 姓名的非递减字典 {if(strcmp(s1.name,s2.name)==0) return strcmp(s1.num,s2.num)<0; else return strcmp(s1.name,s2.name)<0; } int cmp3(student s1,student s2)//case3 {if(s1.grade==s2.grade) return strcmp(s1.num,s2.num)<0; else return s1.grade<s2.grade; } int main() {int N,C;int count=0;while(scanf("%d %d",&N,&C)!=EOF){count++;if(N==0 && C==0) return 0;int i;for(i=0;i<N;i++)scanf("%s %s %d",s[i].num,s[i].name,&s[i].grade);switch(C){case 1:{sort(s,s+N,cmp1);break;}case 2:{sort(s,s+N,cmp2);break;}case 3:{sort(s,s+N,cmp3);break;} }printf("Case %d:\n",count);for(i=0;i<N;i++)printf("%s %s %d\n",s[i].num,s[i].name,s[i].grade); }return 0; }
转载于:https://www.cnblogs.com/jianrenguo/p/6555676.html
题目1023:EXCEL排序---------Case后面的是count,不是C相关推荐
- c语言case后接printf,C编程中switch。case 问题
int main() { int imonth; printf("请输入月份:\n"); scanf_s("%d",&imonth,2); switch ...
- 题目4:EXCEL排序
http://ac.jobdu.com/problem.php?cid=1040&pid=3 题目描述: Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. 对每个测试用例 ...
- R7-9 模拟EXCEL排序 (25 分)
R7-9 模拟EXCEL排序 (25 分) Excel可以对一组纪录按任意指定列排序.现请编写程序实现类似功能. 输入格式: 输入的第一行包含两个正整数N(≤105) 和C,其中N是纪录的条数,C是指 ...
- C语言 qsort的用法 模拟EXCEL排序
C语言 qsort的用法 模拟EXCEL排序 题目 Excel可以对一组记录按任意指定列排序.现请编写程序实现类似的功能. 输入 输入的第一行包含两个正整数N(<= 10^5)和C,其中N是记录 ...
- C++EXCEL排序
C++EXCEL排序 Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. Input 测试输入包含若干测试用例.每个测试用例的第1行包含两个整数 N (<=100000) 和 ...
- 1926 Problem C EXCEL排序
问题 C: EXCEL排序 时间限制: 1 Sec 内存限制: 32 MB 题目描述 Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. 对每个测试用例,首先输出1行" ...
- 问题 C: EXCEL排序
http://codeup.cn/problem.php?cid=100000581 题目描述 Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. 对每个测试用例,首先输出1行&q ...
- 算法笔记1926ProblemC Excel排序
题目描述 Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. 对每个测试用例,首先输出1行"Case i:",其中 i 是测试用例的编号(从1开始).随后在 N ...
- 算法笔记4.1问题 C: EXCEL排序
题目描述 Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. 对每个测试用例,首先输出1行"Case i:",其中 i 是测试用例的编号(从1开始).随后在 N ...
最新文章
- Excel、Exchange和C#
- keil调用bat文件,实现删除、复制、加密文件功能
- 最长上升子序列问题 (LIS)
- How is SCM product maintenance tcode redirecting access to MARA
- spring-boot注解详解(六)
- librtmp分析(发送数据包处理)
- Python找出某元素的索引下标
- FLEX常用验证控件
- 6 EDA技术实用教程【基础知识2】
- tcl语言读取文件一行_TCL语言笔记:TCL中的列表操作
- beatmaker3 android,faded打击垫
- ASIC设计流程相关
- C语音 unsigned char, int的取值范围
- 借鉴华为HiLink实现微信小程序智能配网功能
- 金和IUapp制作“手机之家”
- 关于win10X64 连接oracle
- ffiddler抓取手机(app)https包
- stl文件怎么用Java读取_将STEP文件转换为STL
- Git详解之四:服务器上的Git
- C++break语句用法