当前位置:网站首页>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
边栏推荐
- 精度、速度完美平衡,最新图像分割SOTA模型重磅发布!!!
- mysql中 innoDB执行过程分析
- 5 free audio material websites, recommended collection
- Van uploader upload picture implementation process, using native input to upload pictures
- Recommended website for drawing result map
- Embrace the new blue ocean of machine vision and hope to open a new "Ji" encounter for the development of digital economy
- 如何防止网站被黑客入侵篡改
- Process virtual address space partition
- 梳理網絡IP代理的幾大用途
- Introduction to metalama 4 Use fabric to manipulate items or namespaces
猜你喜欢

Use compressorjs to compress pictures, optimize functions, and compress pictures in all formats

Zigbee之CC2530最小系统及寄存器配置(1)

Aviation core technology sharing | overview of safety characteristics of acm32 MCU

mysql8安装

Realize several "Postures" in which a box is horizontally and vertically centered in the parent box

Unable to create servlet under SRC subfile of idea

mysql中 innoDB执行过程分析

进程虚拟地址空间区域划分

How to prevent the website from being hacked and tampered with

Can I take the CPDA data analyst certificate for 0 foundation
随机推荐
Kubernetes 入門教程
5 free audio material websites, recommended collection
Record the problems encountered in using v-print
XinChaCha Trust SSL Organization Validated
Van uploader upload picture implementation process, using native input to upload pictures
Keyword interpretation and some APIs in RT thread
Resolve disagrees about version of symbol device_ create
Use source insight to view and edit source code
Luogu p3236 [hnoi2014] picture frame solution
4. DRF permission & access frequency & filtering & sorting
Aviation core technology sharing | overview of safety characteristics of acm32 MCU
教你快速开发一个 狼人杀微信小程序(附源码)
如何实现点击一下物体播放一次动画
云原生KubeSphere部署Mysql
There is no need to crack the markdown editing tool typora
[unity note] basic lighting in l4unity
网站首页文件被攻击篡改的形式有哪些
【csnote】ER图
Pre competition practice of TIANTI competition
Importerror after tensorflow installation: DLL load failed: the specified module cannot be found, and the domestic installation is slow