1028 List Sorting (25 分)

保姆级教程:在S32K312上配置C40驱动,实现Flash读写(基于RTD 4.4.2) 本文详细介绍了在S32K312微控制器上配置C40驱动实现Flash读写的全流程,基于RTD 4.4.2库。内容涵盖环境搭建、外设配置、Flash操作实战代码及高级应用场景,特别针对LLD驱动和FLS存储操作中的常见问题提供了解决方案,帮助开发者快速掌握嵌入式Flash存储技术。 阅读详情

在这里插入图片描述
1028 List Sorting (25 分)
Excel can sort records according to any column. Now you are supposed to imitate this function.

Input Specification:
Each input file contains one test case. For each case, the first line contains two integers N (≤10
5
) and C, where N is the number of records and C is the column that you are supposed to sort the records with. Then N lines follow, each contains a record of a student. A student’s record consists of his or her distinct ID (a 6-digit number), name (a string with no more than 8 characters without space), and grade (an integer between 0 and 100, inclusive).

Output Specification:
For each test case, output the sorting result in N lines. That is, if C = 1 then the records must be sorted in increasing order according to ID’s; if C = 2 then the records must be sorted in non-decreasing order according to names; and if C = 3 then the records must be sorted in non-decreasing order according to grades. If there are several students who have the same name or grade, they must be sorted according to their ID’s in increasing order.

Sample Input 1:
3 1
000007 James 85
000010 Amy 90
000001 Zoe 60
Sample Output 1:
000001 Zoe 60
000007 James 85
000010 Amy 90
Sample Input 2:
4 2
000007 James 85
000010 Amy 90
000001 Zoe 60
000002 James 98
Sample Output 2:
000010 Amy 90
000002 James 98
000007 James 85
000001 Zoe 60
Sample Input 3:
4 3
000007 James 85
000010 Amy 90
000001 Zoe 60
000002 James 9
Sample Output 3:
000002 James 9
000001 Zoe 60
000007 James 85
000010 Amy 90

#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
struct Student {
	char ID[10];
	char name[10];
	int grade;
}student[100005];
bool cmp1(Student a, Student b) {
	if (a.ID != b.ID) return strcmp(a.ID, b.ID) < 0;
}
bool cmp2(Student a, Student b) {
	if (strcmp(a.name,b.name)==0) return strcmp(a.ID, b.ID) < 0;
	else return strcmp(a.name, b.name) < 0;
}
bool cmp3(Student a, Student b) {
	if(a.grade==b.grade) return strcmp(a.ID, b.ID) < 0;
	else  return a.grade < b.grade;
}
int main() {
	int N, C;
	cin >> N >> C;
	for (int i = 0; i < N; i++) cin >> student[i].ID >> student[i].name >> student[i].grade;
	if (C == 1) {
		sort(student, student + N, cmp1);
	}
	else if (C == 2) {
		sort(student, student + N, cmp2);
	}
	else {
		sort(student, student + N, cmp3);
	}
	for (int j = 0; j < N; j++) cout << student[j].ID << " " << student[j].name << " " << student[j].grade << endl;
	return 0;
}
Windows下OpenMBEE项目MMS部署失败经历及改正 在Github里找到了上面的第一份文档,下载了MMS源代码(不知道为什么这个代码跟上面操作克隆得到的MMS代码不一样?好像是因为Gradle的版本问题,我本地之前已经安装过7.6.4的Gradle了,于是我找到gradle-wrapper.properties文件。后面在VScode中运行了一下依然是报这个错误,我在VScode终端直接执行。不知道为什么依然没什么用。打开“Windows PowerShell”。(如果是第一次运行它,将看到更长的输出)导航到要克隆存储库的文件夹,例如, 阅读详情

相关推荐

【软考高项】五十一、常见必会的几种进度网络图(单代号、双代号、七格图、横道图)

软考高项计算题进度网络图画图介绍

有莘不破的博客 3万+

A1028 List Sorting (25 分)

1028 List Sorting (25 分) 解题思路        一道常规的排序题,涉及到多个维度,具体按照哪个维度排序取决于输入的参数C。根据题意我们可以为每一种情况写一个cmp函数,但是出题人显然不希望我们这么干。因为按照出题人的习惯,一般都是成绩高的放在前面,但是这次是按照成绩递增(非减)排序,这样无论C等于多少,我们都是递增排序,由此为统一的...

LinxRds的博客 571

PTA编程—币值转换

我对于这个题的主要思想就是把九位数分三块,对每块进行处理后,再合并。有了这个思想就开始写代码,后面就是哪有洞补哪,哪个测试用例没通过就对其特殊处理…。反正最后测试用例全通过了。 #include<iostream> #include <string> #include <algorithm> using namespace std; char a[10]={'a','b','c','d','e','f','g','h','i','j'}; //既然题目说了最多9位

uyo9ko的博客 991

1028 List Sorting (25 分)

1028List Sorting(25分) Excel can sort records according to any column. Now you are supposed to imitate this function. Input Specification: Each input file contains one test case. For each case, t...

树叶子的博客 378

开发板的使用

一、开发板使用学习大纲。 1、开发板组成、核心板资源,底板资源。 2、开发板连接、调试工具、串口参数配置。 3、开发板启动过程。 4、文件传输 1)使用串口传输。 上传/下载 2)使用网口传输。 上传/下载 5、临时/永久配置开发板IP地址。 6、开发板启动脚本。 二、开发板的组成。 核心板: CPU处理器: 芯片:S5P6818(三星) 内核: ARM cortex-A53 -> 八核处理器 运行内存:512MB*2=1G nandflash:4G 底板: 电源线:5V 串口...

qq_45633736的博客 2659

触摸延时灯课程设计

Multisim源文件下载: 实验名称:­­­­­­­­­­­­­­­­­­­ 课程设计1:触摸延时灯仿真设计 设计要求: 利用单稳态触发器设计触控延时灯,要求利用触发波形的边沿模拟触控点实现触发,触发后3秒灯亮,灯可以亮的时间可在5-10秒之间可调。 设计思路: 利用集成单稳态触发器CD4098设计简易的触摸延时灯电路。应用CD4098可以实现脉冲延时,原理图如下。4脚未触发信号输入端,可通过比较器对触摸产生的信号进行比较后再产生触发信号,使触发准确度得以提高。...

m0_54240221的博客 1万+

1028 List Sorting (25分)

Excel can sort records according to any column. Now you are supposed to imitate this function. Input Specification: Each input file contains one test case. For each case, the first line contains two ...

DayDream_x的博客 250

uniapp - 解决App端报错reportJSException >>>> exception function:createInstanceContext, exception:white sc

uni-app,安卓Android,苹果ios,安卓app端,苹果App端,uniapp苹果安卓app,uniApp报错,reportJSException>>>>exceptionfunction:createInstanceContext,exception:whitescreencausecreateinstanceContextfailed,运行自定义基座时白屏,uniapp项目运行白屏reportJSException,检查没问题依旧报错,第三方库插件,组件,uniapp打包调试

🏆 前端领域优质创作者 1万+

1028 List Sorting (25 分)

问题描述:给定记录,按照指定要求排序 解题思路:直接按照要求调用排序sort函数即可 AC代码: #include<bits/stdc++.h> using namespace std; struct student{ //char name[10]; //用char类型方便字符输出。 string name,id; int grade; }stu[100005];...

lianwaiyuwusheng的博客 268

从 SAP GUI 走向 SAP Fiori:一套面向 SAP S/4HANA 的用户迁移实战方法论

SAP S/4HANA转型中,用户从SAP GUI迁移到Fiori的难点在于业务价值的重构而非简单的界面替换。Fiori的核心价值在于角色化、实时洞察和智能决策,而非完全替代GUI。成功迁移需分阶段推进:先展示关键角色的价值,建立统一入口,再逐步提高Fiori占比。让用户参与设计比后期培训更重要,需通过具体场景(如采购优先级管理)展示效率提升。迁移策略应平衡新旧界面优势,让Fiori成为业务价值触达的主要方式,而非强制替换。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 236

24、无人机能耗模型与上下文质量管理的研究

本文系统介绍了无人机能耗模型与上下文质量管理的研究进展。详细阐述了Dorling、Stolaroff、Kirchstein和Tseng等经典能耗模型的原理及特点,并基于LSTM架构构建了数据驱动的能耗预测模型,实验表明其预测精度显著优于传统模型。此外,还探讨了物联网环境中的上下文质量管理问题,引入了conQeng框架,以提升上下文选择、测量和验证的效率与可靠性。研究为无人机能耗优化和物联网上下文管理提供了理论支持和技术方案。

palm99的专栏 344

【1028】List Sorting (25 分)

#include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<algorithm> #include<map> #include<vector> #inclu...

发现问题,并解决问题,批判性思维 308

软件测试高频面试题 2026 最新整理(功能 + 自动化)

本文系统整理了2026年软件测试面试高频题目及参考答案,涵盖功能测试、自动化测试及新兴热点领域。功能测试部分包含测试基础概念、用例设计方法、缺陷管理流程等10个必背题;自动化测试部分详细解析工具选择、元素定位、框架搭建等10个热门考点;新增章节聚焦AI测试、安全测试、性能指标等5个前沿话题。参考答案均采用结构化表述,包含定义、区别、适用场景等关键要素,并强调结合项目经验作答。文末提供2026版面试技巧,建议采用"结论-分点-总结"的回答逻辑,重点展现问题解决能力和技术前瞻性。

SmallBull的博客 1968

PAT甲级 1028 List Sorting (25分)

1028 List Sorting (25分) 题目链接:PAT A 1028 题目大意:题目输入一个数n为学生个数,对于每个学生,给出他们的id,名字以及成绩。输入一个c代表行数,即我们需要排序的行数。如果c为1,则按照id升序排列,如果c为2,则按照名字字母序升序排列,如果名字相同,按照id升序排列,如果c为3,按照成绩升序排列,如果成绩相同,按照id升序排列。 思路分析:很简单的排序题,...

weixin_43684054的博客 197

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

1028 List Sorting (25 分)(排序)

Excel can sort records according to any column. Now you are supposed to imitate this function. Input Specification: Each input file contains one test case. For each case, the first line contains two...

qq_42068614的博客 392

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

PAT A1028 List Sorting (25分)

PAT甲级:A1028 List Sorting (25分) Excel can sort records according to any column. Now you are supposed to imitate this function. Input Specification: Each input file contains one test case. For each case...

只想用最简短的代码刷题 202

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

上一篇: 1062 Talent and Virtue (25 分)
下一篇: 1055 The World‘s Richest (25 分)
好想当依蕾娜小姐的狗
博客等级 码龄7年 0粉丝 62原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值