zoj 2727 List the Books(排序)

poj习题及答案 西北工业大学基本的有关C语言实验的习题及答案 立即下载

链接:zoj 2727

Jim is fond of reading books, and he has so many books that sometimes it's hard for him to manage them. So he is asking for your help to solve this problem.

Only interest in the name, press year and price of the book, Jim wants to get a sorted list of his books, according to the sorting criteria.

Input

The problem consists of multiple test cases.

In the first line of each test case, there's an integer n that specifies the number of books Jim has. n will be a positive integer less than 100. The next n lines give the information of the books in the format Name Year Price. Name will be a string consisting of at most 80 characters from alphabet, Year and Price will be positive integers. Then comes the sorting criteria, which could be Name, Year or Price.

Your task is to give out the book list in ascending order according to the sorting criteria in non-ascendent order.

Note: That Name is the first criteria, Year is the second, and Price the third. It means that if the sorting criteria is Year and you got two books with the same Year, you'd sort them according to their Name. If they equals again, according to their Price. No two books will be same in all the three parameters.

Input will be terminated by a case with n = 0.

Output

For each test case, output the book list, each book in a line. In each line you should output in the format Name Year Price, the three parameters should be seperated by just ONEspace.

You should output a blank line between two test cases.

Sample Input

3
LearningGNUEmacs 2003 68
TheC++StandardLibrary 2002 108
ArtificialIntelligence 2005 75
Year
4
GhostStory 2001 1
WuXiaStory 2000 2
SFStory 1999 10
WeekEnd 1998 5
Price
0

Sample Output

TheC++StandardLibrary 2002 108
LearningGNUEmacs 2003 68
ArtificialIntelligence 2005 75

GhostStory 2001 1
WuXiaStory 2000 2
WeekEnd 1998 5
SFStory 1999 10

代码:

#include<cstdio>
#include<cstring>
#include<algorithm>
struct stu
{
    char n[90];
    int y,p;
};
using namespace std;
int cmp1(struct stu a,struct stu b)
{
    if(strcmp(a.n,b.n)!=0)
        return strcmp(a.n,b.n)<0?1:0;
    if(a.y!=b.y)
        return a.y<b.y;
    return a.p<b.p;
}
int cmp2(struct stu a,struct stu b)
{
    if(a.y!=b.y)
        return a.y<b.y;
    return a.p<b.p;
}
int cmp3(struct stu a,struct stu b)
{
    return a.p<b.p;
}
int main()
{
    struct stu s[110];
    char c[8];
    int i,k=0,n;
    while(scanf("%d",&n)!=EOF){
        if(n==0)
            break;
        k++;
        if(k>1)
            printf("\n");
        for(i=1;i<=n;i++)
            scanf("%s%d%d",s[i].n,&s[i].y,&s[i].p);
        scanf("%s",c);
        if(strcmp(c,"Name")==0)
            sort(s+1,s+1+n,cmp1);
        else if(strcmp(c,"Year")==0)
            sort(s+1,s+1+n,cmp2);
        else if(strcmp(c,"Price")==0)
            sort(s+1,s+1+n,cmp3);
        for(i=1;i<=n;i++)
            printf("%s %d %d\n",s[i].n,s[i].y,s[i].p);
    }
    return 0;
}

Rust 编译工具链配置指南:从 link.exe 缺失到完美解决 本文详细解析了Windows下Rust编译时常见的'link.exe not found'错误,提供了MSVC和MinGW-w64两种工具链的完整配置指南。从Visual Studio组件安装到环境变量设置,再到疑难排查技巧,帮助开发者彻底解决Rust编译工具链配置问题,提升开发效率。 阅读详情

相关推荐

51单片机定时器的原理、应用与编程实现

本文系统介绍了51单片机定时器的基本原理与应用。首先阐述了定时器的工作原理,包括定时模式和计数模式的区别。然后详细讲解了定时器的四种工作模式(方式0-方式3)及其适用场景,并分析了相关寄存器(TMOD、TCON、THx/TLx)的功能设置。文章还给出了定时器编程的具体步骤,包括初始化、计数初值计算和示例代码。最后通过LED闪烁、PWM波形产生、脉冲计数等实际应用案例,展示了定时器的多样化应用。掌握这些知识对嵌入式系统开发具有重要意义。

2501_91227323的博客 1538

15.List the Books——列出书籍

Description Jim is fond of reading books, and he has so many books that sometimes it's hard for him to manage them. So he is asking for your help to solve this problem. Only interest in the name, pre...

qq_41886231的博客 896

HyperMesh实战:5种复杂载荷场景下的field映射技巧(附TCL脚本)

本文详细介绍了HyperMesh在5种复杂载荷场景下的field映射技巧,包括轴承载荷的圆柱坐标系映射、粉末压力中的切向力处理、实验数据到有限元模型的场映射、多工况载荷的组合映射以及局部细化网格的边界条件传递。通过实战案例和TCL脚本,帮助工程师高效解决有限元分析中的载荷映射难题,提升工作效率。

fanta的博客 308

《ACM书中题目》 V

原题 Description Jim is fond of reading books, and he has so many books that sometimes it’s hard for him to manage them. So he is asking for your help to solve this problem. Only interest in th

qinglys的博客 337

Type-C转DP1.4转C双向互传转接线方案

Type-C转DP双向互转方案的核心在于利用Type-C接口中的Alt Mode(交替模式)功能。通过利用Type-C接口的Alt Mode功能,该方案实现了Type-C接口与DP接口之间的双向互传,极大地丰富了用户的视觉体验。在选择Type-C转DP双向互转方案时,用户需要关注兼容性、性能需求、线缆长度和品牌等因素,以确保获得最佳的传输质量和使用体验。因此,Type-C转DP双向互转方案应运而生,旨在实现Type-C接口与DP接口之间的无缝连接,满足用户对高效能和高清晰度视频传输的需求。

m0_70875024的博客 4995

解决Docker拉取镜像报错:Get https://registry-1.docker.io/v2/: 报错

解决Docker拉取镜像报错: Get “https://registry-1.docker.io/v2/”: net/http: request canceled while waiting for connection问题描述Get "https://registry-1.docker.io/v2/"是docker官方的镜像源,下载很慢的,一般会自己指定国内映射的加速镜像源。

qq_33650333的博客 4187

三级排序 qsort zoj 2727

qsort 三级排序问题 zoj 2727(水题) 这道题真的困扰我很长时间,算法确实很简单,就是代码格式上出错,自己的编译器都过了,OJ上很坑人啊,各种编译错误,后来各种网搜,查找,至今不知为何这样做,但是还是拿出来供大家参考   出错部分: typedef struct Book { char name[100]; int y; int p; }book;

勇敢的程序猿~.~ 933

使用 Java + PaddleOCR 实现表格识别,支持导出 HTML 和 Excel(附源码)

使用Java+PaddleOCR快速搭建表格识别系统,无需处理底层模型细节。系统支持表格结构识别和内容识别,可将图片转换为可编辑表格格式。文章提供了完整的实现流程,包括Maven依赖引入、模型下载(包含检测、识别、分类和表格结构模型)及参数配置说明。SmartJavaAI支持多种高性能模型选择,适用于不同应用场景,帮助开发者快速实现表格识别功能。

deng775747758的博客 1489

ZOJ2727

一道水题 数据小 用效率最低的冒泡都能过 我这是用的c++的sort 注意有个坑的地方:You should output a blank line between two test cases. 也就是最后一组样例输出没有空行 #include<stdio.h>#include<string.h>#include<algorithm>#include&lt...

weixin_30586085的博客 164

8-bit量化在YOLOv11中的部署实践-(使用PTQ、QAT量化技术实现模型体积压缩和推理加速)

本文系统介绍了YOLOv11模型量化技术,主要包括三个核心部分:首先阐述模型量化的基础理论,包括量化分类、数学原理和性能影响;其次分析YOLOv11架构特点及其量化敏感层;最后详细讲解训练后量化(PTQ)的具体实现流程。研究表明,8-bit量化可使YOLOv11模型大小缩减至1/4,推理速度提升1.7-2.3倍,精度损失控制在1%以内。文章特别强调了校准算法选择(如最小最大值法和KL散度法)对量化效果的关键影响,并提供了完整的代码实现示例,为YOLOv11的高效部署提供实用指导。

本博客聚焦 YOLOv11 全流程落地,涵盖架构优化、数据集处理、训练技巧与多场景部署,兼及国产数据库、Java 开发与 AI 模型应用,内容兼顾理论与工程实践,为开发者提供系统干货,助力高效提升技术能力。 1640

YOLOv13改进策略【损失函数篇】| 2024 引进Focaler-IoU损失函数 加强边界框回归 (Focaler-DIoU、Focaler-GIoU、Focaler-CIoU)

本文记录的是改进YOLOv13的损失函数,将其替换成。现有研究通过利用边界框之间的几何关系来提高回归性能,但忽略了困难样本和简单样本分布对边界框回归的影响。不同检测任务中困难样本和简单样本的分布不同,对于简单样本占主导的检测任务,关注简单样本的边界框回归有助于提高检测性能;对于困难样本比例较高的检测任务,需要关注困难样本的边界框回归。,提高检测器在不同检测任务中的性能。实现的。

Limiiiing的博客 874

zoj2727-------------------List the Books 结构体排序

Jim is fond of reading books, and he has so many books that sometimes it's hard for him to manage them. So he is asking for your help to solve this problem. Only interest in the name, press year and

Life is Float. 739

如何在不牺牲精度的前提下,把 YOLOv11 压缩到 Jetson 能跑的程度

YOLOv11 在目标检测任务中具备较强的准确性与多尺度鲁棒性,但其原始模型参数规模与计算量,对边缘设备来说并不友好,特别是面向 Jetson 这类资源受限的推理平台。本文基于实际部署场景,逐步拆解从结构层级改造、剪枝策略制定、量化导出流程,到 Jetson TensorRT 推理落地全过程。在不牺牲主干精度的前提下,最终实现 YOLOv11 推理延迟缩短 3 倍、模型体积压缩 4 倍、mAP 损失控制在 1% 以内的轻量化优化结果,并总结出一条可复用的工程路径,供工业界与边缘侧模型部署开发者参考。

努力分享一些人工智能、计算机视觉、影像等相关的知识干货! 2439

zoj 2727 List the Books(三级排序 = =水题)

<br />给书的名字,年份,价格排序。<br /> <br />名字优先级大于年份大于价格。<br /> <br />无语死了都 = =。用sort排序,返回值是0或者1,返回2都不行 = =。这个记住了。<br /> <br />#include <stdio.h> #include <stdlib.h> #include <iostream> #include <string.h> #include <algorithm> using namespace std; typedef stru

小媛在努力~ 1554

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

ZOJ 2727 List the Books

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1727 #include #include #include #include using namespace std; struct Book { string Name; int Year; int Price; }; boo

Learn as if you were to live forever 791

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

ZOJ2727 List the Books

 #include#include#includeusing namespace std;struct book{string name;int year;int price;//定义排序规则//name相同时,按year排序,year依旧相同,按price排序bool operator if(name!=t.name)retur

shamoqiuyin的世界 625

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

ZOJ Problem Set - 2727 List the Books

List the Books Time Limit: 2 Seconds      Memory Limit: 65536 KB Jim is fond of reading books, and he has so many books that sometimes it's hard for him to manage them. So he is asking for your

acm_1361677193的专栏 626

ZOJ 2727 List the Books

Jim is fond of reading books, and he has so many books that sometimes it's hard for him to manage them. So he is asking for your help to solve this problem. Only interest in the name, press year and

越努力,越幸运!!! 846

zoj 2727 list the books

<br />   水题。。不会函数重载。。写了三个cmp。。<br />#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; struct type { char name[105]; int year; int price; }; int cmp1(struct type a,struct type b) { if(strcmp(a

个人信息备份站。。 663

zoj 2727 List the Books

List the BooksTime Limit:2 Seconds Memory Limit:65536 KB Jim is fond of reading books, and he has so many books that sometimes it's hard for him to manage them. So he is asking for your help t...

weixin_30624825的博客 137

ZOJ 2727List the Books

#include #include #include #include #include using namespace std; struct Book { string Name; int Year; int Price; }; bool CompName(const Book &b1,const Book &b2) { if(b1.Name!=b2.Name) return b

铁兵的专栏 670

List the Books(sort)

Link: ZOJ Problem Set - 2727 List the Books Time Limit: 2 Seconds      Memory Limit: 65536 KB Jim is fond of reading books, and he has so many books that sometimes it's hard for him

林下的码路 1427

zoj水题分类

zoj水题分类 zoj分类 简单题 #1001 -____-b  A+B。 #1110 Dick and Jane 胡乱枚举收缩一下情况就可以了。(这题脑筋还是要转一个弯的,不然做不出) #1115 a[i+1] = a[i] 的全部数位上的加起来,直到剩下一个,直接模拟。 #1414 太弱太弱,按照模 4 分类讨论一下即可。 #1713 简单的字符串截取

wuzhoudao的专栏 7776

ZOJ-2727

水题一个,快排一下搞定 #include #include #include struct BookStruct { char name[81]; int year; int price; }; typedef struct BookStruct *Book; int cmp_name(const void *p1, const void *p2) { Bo

xhldtc的专栏 657

OJ List the Books

运用sort函数,轻松进行数组排序。

jhgjhg225的博客 274
上一篇: zoj 1109 Language of FatMouse
下一篇: sdibt 3148 To help that magician
happy_lcj
博客等级 码龄13年 7粉丝 152原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址