#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. js实现堆排序

    <script type="text/javascript"> var arr = [22, 31, 1, 9, 99, 68, 55, 30]; function h ...

  2. 网页播放amr格式文件

    mp3格式大家都知道,amr格式就陌生了,至少我没听过.百度一下,先给自己扫盲: AMR(Adaptive Multi-Rate):nokia为WB-AMR格式(AWB)的铃声所作的商业命名,以被3G ...

  3. 用VS2015打开cshtml识图文件的时候会报错 如指定的文件不存在

    用vs2015打开cshtml识图文件的时候会报错.百度后得到解决方法如下: 先关闭VS2015, 拷贝:%LocalAppData%\Microsoft\VisualStudio\14.0\Comp ...

  4. Git CMD - status: Show the working tree status

    命令参数 git status [<options>…​] [--] [<pathspec>…​] 命令格式 --short, -s 短格式输出. -- long 长格式输出, ...

  5. Nhibernate3.3.3sp1基础搭建测试

    实体类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using Syst ...

  6. github果然强大

    github果然强大,在idea里写好,可以直接提交到github,在哪台电脑都可以看源码了,手机也可以看 https://github.com/gaojinhua

  7. ASSERT报错:error C2664: “AfxAssertFailedLine”: 不能将参数 1 从“TCHAR []”转换为“LPCSTR”

    转载请注明来源:崨雁嫀筝 http://www.cnblogs.com/xuesongshu 这个错误是我在把tinyxml修改为宽字符(Unicode)版本时候遇到的问题,我首先按关键字把所有有ch ...

  8. vs2012如何创建报表

    引自百度文库,介绍的比较详细 http://wenku.baidu.com/view/c405d5f48762caaedc33d405.html

  9. cocos2dx-lua class语法糖要注意了

    cocos2dx-lua function.lua 定义了class方法,让lua实现继承像传统语言一样漂亮和方便 看定义 function class(classname, super) local ...

  10. struts2文件上传(保存为BLOB格式)

    html文件:提供上传文件的入口 <input type="file" name="upload"><!-- name很重要,与后面actio ...