#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. 不支持关键字:metadata

    将 string sqlConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Cos ...

  2. [改善Java代码]适时选择不同的线程池来实现

    Java的线程池实现从最根本上来说只有两个:ThreadPoolExecutor类和ScheduledThreadPoolExecutor类,这两个类还是父子关系,但是Java为了简化并行计算,还提供 ...

  3. hdu 4614 线段树

    思路:当k为1的时候,用二分法查询包含有f个空瓶的上界r,然后更新会方便很多,直接更新区间(a,r)了. #include<iostream> #include<cstdio> ...

  4. web项目的两个创建形式website和webapplication(转)

    前言 在利用VS2010创建web项目的时候,会有两个选择.可以选择直接创建website网站,还可以选择使用 webapplication应用程序.刚刚接触web开发,看到这两个就疑惑了,既然是都可 ...

  5. Next Power of 2

    Next Power of 2 Write a function that, for a given no n, finds a number p which is greater than or e ...

  6. Android实现贪吃蛇游戏

    [绥江一百]http://www.sj100.net                                                  欢迎,进入绥江一百感谢点击[我的小网站,请大家多 ...

  7. Activity的启动模式(android:launchMode)

    在android里,有4种activity的启动模式,分别为: “standard” (默认) “singleTop” “singleTask” “singleInstance” 它们主要有如下不同: ...

  8. SQL自动补充其他月份为0

    ,) ), Sales int,Dates datetime) insert into ProductSale ,'2014-01-05' UNION ALL ,'2014-02-05' UNION ...

  9. swift闭包传值

    不知道原理,就知道这么用的,皮毛上的那一点. 寻思着把以前的项目改成swift的,结果了,,, 反向传值 一. //类似于OC中的typedef typealias sendValueClosure= ...

  10. css3学习笔记之图片

    圆角图片 border-radius: 圆角图片: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <!DOCTYPE html> <htm ...