当前位置:网站首页>Byte jump 2020 autumn recruitment programming question: quickly find your own ranking according to the job number
Byte jump 2020 autumn recruitment programming question: quickly find your own ranking according to the job number
2022-04-23 12:56:00 【Play ha ha 527】
Topic content : Quickly find your own ranking according to your job number .
Enter an integer in the first line n Total number of Representatives ;
On the second line, enter an integer m Represent your job number ( Job No m The order of the inputs );
On the third line, enter everyone's score .
give an example
5 // The total number of 5 personal
2 // The job number is 2
5 4 3 2 1 //5 The individual scores in order are 5 branch ,4 branch ,3 branch ,2 branch ,1 branch
Find out that the job number is 2 The ranking of is used as the output . Be careful : Enter here in order , Job number 0 Is the first person , got 5 branch , Job number 2 That's it 3 branch , Output 3 Ranking in everyone's score , That's the third place , Output value 3.
Program reference example :
import java.util.*;
public class test17_zijie {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int n=in.nextInt();// The total number of n
int m=in.nextInt();// Your job No m individual
int arr[]=new int[n];// The length is n To store scores
int k=0;
int res=0;// Ranking initialization
int score=0;
while(n>0) {
arr[k++]=in.nextInt();// The scores entered are stored in the array in turn
n--;
}
score=arr[m];// Job number m Corresponding score
Arrays.sort(arr);// Sort all the data of the array from small to large
for (int i = 0; i < arr.length; i++) {
if(score==arr[i]) {
//System.out.println(i);
res=arr.length-i;// Ranking
}
}
System.out.println(res);
}
}
Maybe there are better ideas, ha ha , The brain is not idle, so stop here .
版权声明
本文为[Play ha ha 527]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230615231530.html
边栏推荐
- 进程虚拟地址空间区域划分
- 实现一个盒子在父盒子中水平垂直居中的几种“姿势”
- Ad20 supplementary note 3 - shortcut key + continuous update
- bert-base-chinese下载(智取)
- SSM框架系列——Junit单元测试优化day2-3
- BUUCTF WEB [BJDCTF2020]ZJCTF,不过如此
- Zero trust in network information security
- STM32控制步进电机(ULN2003+28byj)
- Get the punch in record of nailing attendance machine
- [csnote] ER diagram
猜你喜欢
Record a website for querying compatibility, string Replaceall() compatibility error
Aviation core technology sharing | overview of safety characteristics of acm32 MCU
Free and open source agricultural Internet of things cloud platform (version: 3.0.1)
Labels and paths
SSL certificate refund instructions
Process virtual address space partition
Can I take the CPDA data analyst certificate for 0 foundation
Number of nodes of complete binary tree
STM32工程移植:不同型号芯片工程之间的移植:ZE到C8
Wonderful review | the sixth issue of "source" - open source economy and industrial investment
随机推荐
The continuous construction of the Internet industry platform is not only able to collect traffic
云原生KubeSphere部署Redis
SSM framework series - annotation development day2-2
Zero trust in network information security
5 free audio material websites, recommended collection
网站首页文件被攻击篡改的形式有哪些
洛谷P5540 [BalkanOI2011] timeismoney | 最小乘积生成树 题解
BUUCTF WEB [BJDCTF2020]The mystery of ip
Markdown grammar learning
BaseRecyclerViewAdapterHelper 实现下拉刷新和上拉加载
Object. The disorder of key value array after keys
Web17 -- use of El and JSTL
Common problems of unity (1)
SSM框架系列——注解开发day2-2
How to click an object to play an animation
Importerror after tensorflow installation: DLL load failed: the specified module cannot be found, and the domestic installation is slow
SSM framework series - data source configuration day2-1
Software testing weekly (issue 68): the best way to solve difficult problems is to wait and see the changes and push the boat with the current.
在线计算过往日期天数,计算活了多少天
Synchronously update the newly added and edited data to the list