news 2026/11/6 1:19:03

01:谁考了第k名

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
01:谁考了第k名
/** * 题目名称:谁考了第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());}}
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/11/6 1:16:28

Design Compiler:语法检查工具dcprocheck

相关阅读 Design Compilerhttps://blog.csdn.net/weixin_45791458/category_12738116.html?spm1001.2014.3001.5482 dcprocheck是一个在Design Compiler存在于安装目录下的程序&#xff08;其实它是一个指向snps_shell的符号链接&#xff0c;但snps_shell可以根据启动命令名判…

作者头像 李华
网站建设 2026/11/6 1:15:11

Verilog基础:生成块结构(Generate)

相关阅读 Verilog基础https://blog.csdn.net/weixin_45791458/category_12263729.html?spm1001.2014.3001.5482 目录 简介 循环生成块结构 条件生成块结构 直接嵌套 匿名生成块的接口名 简介 生成块结构(Generate)用于有条件地&#xff08;称为条件生成块&#xff09;或重复地…

作者头像 李华
网站建设 2026/11/6 1:15:00

8GB显卡跑通AI视频生成的最短路径:WAN2.2 四步出片指南

8GB显卡跑通AI视频生成的最短路径&#xff1a;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…

作者头像 李华