#include <vector>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; struct MyStruct
{
char ID[];
char name[];
int grade;
}; int cmp1(MyStruct a,MyStruct b)
{
return (strcmp(a.ID,b.ID)<);
} int cmp2(MyStruct a,MyStruct b)
{
if(strcmp(a.name,b.name)==) return (strcmp(a.ID,b.ID)<);
else return strcmp(a.name,b.name)<;
} int cmp3(MyStruct a,MyStruct b)
{
if(a.grade==b.grade) return (strcmp(a.ID,b.ID)<);
else return a.grade<b.grade;
} int main()
{
int n,c,i;
while(scanf("%d %d",&n,&c)!=EOF)
{
vector <MyStruct> vv;
for(i=;i<n;i++)
{
MyStruct tem;
getchar();
scanf("%s %s %d",tem.ID,tem.name,&tem.grade);
vv.push_back(tem);
}
if(c==)
sort(vv.begin(),vv.end(),cmp1);
if(c==)
sort(vv.begin(),vv.end(),cmp2);
if(c==)
sort(vv.begin(),vv.end(),cmp3); for(i=;i<n;i++)
printf("%s %s %d\n",vv[i].ID,vv[i].name,vv[i].grade); }
return ;
}

1028. List Sorting (25)的更多相关文章

  1. PAT 甲级 1028 List Sorting (25 分)(排序,简单题)

    1028 List Sorting (25 分)   Excel can sort records according to any column. Now you are supposed to i ...

  2. 【PAT】1028. List Sorting (25)

    题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1028 题目描述: Excel can sort records according to an ...

  3. PAT 甲级 1028. List Sorting (25) 【结构体排序】

    题目链接 https://www.patest.cn/contests/pat-a-practise/1028 思路 就按照 它的三种方式 设计 comp 函数 然后快排就好了 但是 如果用 c++ ...

  4. PAT (Advanced Level) Practice 1028 List Sorting (25 分) (自定义排序)

    Excel can sort records according to any column. Now you are supposed to imitate this function. Input ...

  5. 1028 List Sorting (25 分)

    Excel can sort records according to any column. Now you are supposed to imitate this function. Input ...

  6. PAT 1028 List Sorting (25分) 用char[],不要用string

    题目 Excel can sort records according to any column. Now you are supposed to imitate this function. In ...

  7. PAT (Advanced Level) 1028. List Sorting (25)

    时间卡的比较死,用string会超时. #include<cstdio> #include<cstring> #include<cmath> #include< ...

  8. PAT甲题题解-1028. List Sorting (25)-水排序

    #include <iostream> #include <cstdio> #include <algorithm> #include <string.h&g ...

  9. 【PAT甲级】1028 List Sorting (25 分)

    题意: 输入一个正整数N(<=100000)和C(C属于{1,2,3}),接下来输入N行,每行包括学生的六位学号(习惯用string输入,因为可能有前导零),名字和成绩(正整数).输出排序后的信 ...

随机推荐

  1. c# 操作word

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  2. 使用apache和IIS,共用80端口的一个解决方案【转】

    将apache设为使用80端口,IIS使用其它端口,比如81,然后将apache作为IIS的代理. 在httpd.conf里面,取消下面四行的注释: LoadModule proxy_module m ...

  3. MySQL5.6 linux源码安装

    安装mysql 创建mysql数据目录 mkdir -p /usr/local/mysql --安装目录 mkdir -p /mysql/data ---数据目录 mkdir -p /mysql/lo ...

  4. cx_Oracle安装说明

    简介 cx_Oracle是用python连接oracle的驱动模块,参考文章: [cx_Oracle文档](http://cx-oracle.sourceforge.net/html/index.ht ...

  5. Eclipse+Axis自动生成Web Service WSDL文件

    JDK版本:1.5.0_22 Eclipse版本:Helios Service Release 2(3.6.2) 首先创建一个web工程,创建过程如下: 如果选择Apache Tomcat v5.5, ...

  6. [改善Java代码]覆写equals方法必须覆写hashCode方法

    覆写equals方法必须覆写hashCode方法,这条规则基本上每个Javaer都知道,这也是JDK API上反复说明的,不过为什么要这样做呢?这两个方法之间有什么关系呢?本建议就来解释该问题,我们先 ...

  7. Jersey(1.19.1) - XML Support

    As you probably already know, Jersey uses MessageBodyWriters and MessageBodyReaders to parse incomin ...

  8. sqlserver 测试sql语句执行时间

    查看sql语句执行时间/测试sql语句性能 写程序的人,往往需要分析所写的SQL语句是否已经优化过了,服务器的响应时间有多快,这个时候就需要用到SQL的STATISTICS状态值来查看了. 通过设置S ...

  9. Linux命令(5):cp命令

    1.作用: 将给出的文件或目录复制到另一文件或目录中: 2.格式: cp  [选项] 源文件或目录 目标文件或目录. 3.常见参数: 4.使用实例: [root@localhost ~]# cp -a ...

  10. 如何查看eclipse或Myeclipse的版本号

    对于eclipse 方法一: 在eclipse安装路径下用记事本打开 .eclipseproduct文件,里面就有eclipse版本号. 形如: name=Eclipse Platform id=or ...