PAT (Advanced Level) 1028. List Sorting (25)
时间卡的比较死,用string会超时。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std; struct X
{
int id;
char name[];
int score;
}s[+];
int n,C; bool cmp1(const X&a,const X&b){return a.id<b.id;}
bool cmp2(const X&a,const X&b)
{
if(strcmp(a.name,b.name)==) return a.id<b.id;
return strcmp(a.name,b.name)<;
}
bool cmp3(const X&a,const X&b)
{
if(a.score==b.score) return a.id<b.id;
return a.score<b.score;
} int main()
{
scanf("%d",&n); scanf("%d",&C);
int tot=;
for(int i=;i<=n;i++)
{
scanf("%d",&s[i].id);
scanf("%s",s[i].name);
scanf("%d",&s[i].score);
}
if(C==) sort(s+,s++n,cmp1);
else if(C==)sort(s+,s++n,cmp2);
else sort(s+,s++n,cmp3);
for(int i=;i<=n;i++)
{
printf("%06d ",s[i].id);
printf("%s ",s[i].name);
printf("%d\n",s[i].score);
}
return ;
}
PAT (Advanced Level) 1028. List Sorting (25)的更多相关文章
- PTA (Advanced Level) 1028 List Sorting
List Sorting Excel can sort records according to any column. Now you are supposed to imitate this fu ...
- PAT (Advanced Level) 1114. Family Property (25)
简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...
- PAT (Advanced Level) 1109. Group Photo (25)
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...
- PAT (Advanced Level) 1105. Spiral Matrix (25)
简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #incl ...
- PAT (Advanced Level) 1101. Quick Sort (25)
树状数组+离散化 #include<cstdio> #include<cstring> #include<cmath> #include<map> #i ...
- PAT (Advanced Level) 1071. Speech Patterns (25)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...
- PAT (Advanced Level) 1063. Set Similarity (25)
读入之后先排序. 询问的时候可以o(m)效率得到答案. #include<cstdio> #include<cstring> #include<cmath> #in ...
- PAT (Advanced Level) 1059. Prime Factors (25)
素因子分解. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...
- PAT (Advanced Level) 1051. Pop Sequence (25)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
随机推荐
- php过滤函数
addcslashes — 以 C 语言风格使用反斜线转义字符串中的字符 addslashes — 使用反斜线引用字符串 strip_tags — 从字符串中去除 HTML 和 PHP 标记 stri ...
- URL的# (转)
http://www.ruanyifeng.com/blog/2011/03/url_hash.html
- OpenGL----绘制立方体,定点数组与顶点缓冲
,立方体是很简单,但是这里只是拿立方体做一个例子,来说明OpenGL在绘制方法上的改进.从原始一点的办法开始一个立方体有六个面,每个面是一个正方形,好,绘制六个正方形就可以了. glBegin(GL_ ...
- linux ubuntu平台下安装Scrapy
1.安装Python sudo apt-get install python2.7 python2.7-dev 2.安装pip 下载get-pip.py 选中该文件所在路径,执行下面的命令 sudo ...
- 从零开始学习OpenGL ES之一 – 基本概念
我曾写过一些文章介绍iPhone OpenGL ES编程,但大部分针对的是已经至少懂得一些3D编程知识的人.作为起点,请下载我的OpenGL Xcode项目模板,而不要使用Apple提供的模板.你可以 ...
- gcc 优化选项 -O1 -O2 -O3 -Os 优先级,-fomit-frame-pointer
英文:https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Optimize-Options.html#Optimize-Options 少优化->多优化: ...
- c# 去除文本的html标签
public static string ContentReplace(string input) { input = Regex.Replace(input, @"<(.[^> ...
- Java 学习路线以及各阶段学习书籍,博文,视频的分享
感谢: 感谢每一个打开这篇文章的人,听我在这里瞎扯!至于我为什么会有闲情写这篇文章呢?因为我每天想的是为什么要给我这样的需求,背后的人性是什么,我能再做些什么能让他更好.久而久之,我也稍微有了些自己的 ...
- Photoshop学习之路
网易云课堂中有的提升课程:http://study.163.com/course/courseMain.htm?courseId=765016&6925ecaa9614a750=Individ ...
- jq的事件冒泡
在页面上可以有多个事件,也可以多个元素响应同一件事, 事件冒泡引发的问题: 有些时候不想动用的事件,却因为事件冒泡而触发 解决问题: 1.事件对象 由于IE-DOM和标准的DOM实现事件对象的方法各不 ...