#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. Android数据库的使用

    学了web好久没继续做,现在做android开发断断续续也近一年了,实习是android,现在毕业了工作也是android,但是对于数据库这块由于最近项目需要就研究了下其常用操作,这篇博客中的观点仅代 ...

  2. django–url

    当我们创建了一个项目时,系统为我们创建了一份urlconf, 它可能是这样的: urlpatterns = [ url(r'^admin/', admin.site.urls), ] r'^admin ...

  3. iaas,paas,saas理解

    IaaS.PaaS.SaaS多次看到这几个单词,今天仔细看看来, ​这几个词和云计算相关:1,iaaS,Hardware-as-a-Service,信息,硬件服务,服务器,存储和网络硬件,网络存储,带 ...

  4. LeetCode 278

    First Bad Version You are a product manager and currently leading a team to develop a new product. U ...

  5. GDB基本调试

    调试时gcc -g -Wall -o Hello Hello.c gdb Hello -tui -g: 生成调试信息 -Wall: 编译器警告信息 -W: 警告信息 在调用GDB时,命令行指定-tui ...

  6. 关于线程池ThreadPoolExecutor使用总结

    本文引用自: http://blog.chinaunix.net/uid-20577907-id-3519578.html 一.简介 线程池类为 java.util.concurrent.Thread ...

  7. [设计模式]<<设计模式之禅>>关于开闭原则

    开闭原则是Java世界里最基础的设计原则,它指导我们如何建立一个稳定的.灵活的系统,先来看开闭原则的定义: Software entities like classes,modules and fun ...

  8. JAVA HttpsURLConnection 忽略对SSL valid 的验证

    有时候我们对https进行测试的时候,经常自签署一个证书给server,这个certificate经常是不能通过验证的,但是我们又要用这个https,所以我们经常来忽略对SSL validation的 ...

  9. Ubuntu系统下常用的新建、删除、拷贝文件命令

    我们在Ubuntu系统中安装程序时,经常要在usr目录下新建.拷贝文件,此文件夹在Linux类系统中需要root权限才能访问,因此用常规的鼠标右键菜单操作是无效的,今天分享一下在终端中使用命令新建.拷 ...

  10. android用异步操作AsyncTask编写文件查看器

    Activity程序 package com.example.fileasynctaskproject; import java.io.File; import java.util.ArrayList ...