时间卡的比较死,用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)的更多相关文章

  1. PTA (Advanced Level) 1028 List Sorting

    List Sorting Excel can sort records according to any column. Now you are supposed to imitate this fu ...

  2. PAT (Advanced Level) 1114. Family Property (25)

    简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...

  3. PAT (Advanced Level) 1109. Group Photo (25)

    简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...

  4. PAT (Advanced Level) 1105. Spiral Matrix (25)

    简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<map> #incl ...

  5. PAT (Advanced Level) 1101. Quick Sort (25)

    树状数组+离散化 #include<cstdio> #include<cstring> #include<cmath> #include<map> #i ...

  6. PAT (Advanced Level) 1071. Speech Patterns (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  7. PAT (Advanced Level) 1063. Set Similarity (25)

    读入之后先排序. 询问的时候可以o(m)效率得到答案. #include<cstdio> #include<cstring> #include<cmath> #in ...

  8. PAT (Advanced Level) 1059. Prime Factors (25)

    素因子分解. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...

  9. PAT (Advanced Level) 1051. Pop Sequence (25)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

随机推荐

  1. HTML与DOM BOM javascript

    1.什么是DOM? 简单说就是DOM规定了HTML,XML等的一些文档映射规范,使JavaScript可以根据这些规范来进行获取元素,在元素上进行各种操作,使得用户页面可以动态的变化,从而大大使页面的 ...

  2. window.open弹出窗口调用controller

    前台图片调用js函数 <img src='${pageContext.request.contextPath}/FlatUI/img/link.png' id='report' alt='&qu ...

  3. PHP的反射机制【转载】

    PHP5添加了一项新的功能:Reflection.这个功能使得phper可以reverse-engineer class, interface,function,method and extensio ...

  4. Dominating Patterns

    Dominating Patterns Time Limit:3000MS   Memory Limit:Unknown   64bit IO Format:%lld & %llu Descr ...

  5. oracle_一次移动数据库dbf文件的操作

    oracle数据库的dbf路径下面磁盘不足,需要把原始路径下面的dbf文件移动到另外一个磁盘路径下, 具体的操作有四步. 1.把整个表空间offline. 2.copy原始路径下的dbf文件到新的路径 ...

  6. div.2/C. They Are Everywhere<two pointer>

    题意: 给出包含n (3<=n<=100000)个字符的字符串,计算出包含所有类型字符的最小区间长度. 题解: Two pointer.注意区间的处理. #include<cstdi ...

  7. NSObject Class 浅析

    Objective-C中有两个NSObject,一个是NSObject类,另一个是NSObject协议.而其中NSObject类采用了NSObject协议.在本文中,我们主要整理一下NSObject类 ...

  8. getByClassName2016/4/21

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  9. JS定时器的使用--数码时钟

    <title>无标题文档</title> <script> function toDou(n){ if(n<10){ return '0'+n; }else{ ...

  10. JS中获取页面单选框radio和复选框checkbox中当前选中的值

    单选框:单选框的name值全部相同 页面有一组单选框的元素<td><input type="radio name="radioid">满意< ...