/** * 题目名称:谁考了第k名 <p> * 题目来源:http://noi.openjudge.cn/ch0110/01/ <p> * 程序功能:输出指定名次学生的学号和成绩 * * @author 潘磊,just_panlei@just.edu.cn * @version 1.0 */importjava.util.List;importjava.util.ArrayList;importjava.util.Collections;importjava.util.Scanner;classStudentimplementsComparable<Student>{// 学生类,实现Comparable接口intid;// 学号doublescore;// 成绩publicStudent(intid,doublescore){// 构造方法,初始化学生记录this.id=id;this.score=score;}@Override// 重写compareTo方法,按score降序排序publicintcompareTo(Studento){if(o.score==this.score){// 如果两条记录的score相等return0;// 保持位置不变}returno.score>this.score?1:-1;// 按score降序排序}@Override// 重写toString方法,按题目输出要求返回字符串publicStringtoString(){returnString.format("%d %.1f",id,score);}}publicclassMain{publicstaticvoidmain(String[]args){Scannerinput=newScanner(System.in);intn=input.nextInt();intk=input.nextInt();intid;doublescore;List<Student>students=newArrayList<>();for(inti=0;i<n;i++){id=input.nextInt();score=input.nextDouble();students.add(newStudent(id,score));}Collections.sort(students);// 按自定义规则对students列表排序System.out.print(students.get(k-1).toString());}}01:谁考了第k名
张小明
前端开发工程师
Design Compiler:语法检查工具dcprocheck
相关阅读 Design Compilerhttps://blog.csdn.net/weixin_45791458/category_12738116.html?spm1001.2014.3001.5482 dcprocheck是一个在Design Compiler存在于安装目录下的程序(其实它是一个指向snps_shell的符号链接,但snps_shell可以根据启动命令名判…
Jellyfin Desktop 完整指南:从安装到连上媒体库,10 分钟一步到位
Jellyfin Desktop 完整指南:从安装到连上媒体库,10 分钟一步到位 【免费下载链接】jellyfin-desktop Jellyfin Desktop Client 项目地址: https://gitcode.com/GitHub_Trending/je/jellyfin-desktop 网页端播放器拖个进度条总要等两秒,…
Verilog基础:生成块结构(Generate)
相关阅读 Verilog基础https://blog.csdn.net/weixin_45791458/category_12263729.html?spm1001.2014.3001.5482 目录 简介 循环生成块结构 条件生成块结构 直接嵌套 匿名生成块的接口名 简介 生成块结构(Generate)用于有条件地(称为条件生成块)或重复地…
GSYVideoPlayer 完整使用指南:多内核 Android 视频播放器快速上手
GSYVideoPlayer 完整使用指南:多内核 Android 视频播放器快速上手 【免费下载链接】GSYVideoPlayer Video players (IJKplayer, ExoPlayer, MediaPlayer), HTTPS, 16k page size, danmaku (bullet chat) support, external subtitles, support for filters, waterma…
8GB显卡跑通AI视频生成的最短路径:WAN2.2 四步出片指南
8GB显卡跑通AI视频生成的最短路径:WAN2.2 四步出片指南 【免费下载链接】WAN2.2-14B-Rapid-AllInOne 项目地址: https://ai.gitcode.com/hf_mirrors/Phr00t/WAN2.2-14B-Rapid-AllInOne WAN2.2-14B-Rapid-AllInOne 把文生视频、图生视频压进一个 FP8 文件&am…
3 步搞定群晖「硬盘不受支持」:把第三方盘写入 DSM 兼容数据库(Synology_HDD_db)
3 步搞定群晖「硬盘不受支持」:把第三方盘写入 DSM 兼容数据库(Synology_HDD_db) 【免费下载链接】Synology_HDD_db Add your HDD, SSD and NVMe drives to your Synologys compatible drive database and a lot more 项目地址: https://gi…