当前位置:网站首页>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
边栏推荐
- C, calculation code of parameter points of two-dimensional Bezier curve
- How to click an object to play an animation
- Realize several "Postures" in which a box is horizontally and vertically centered in the parent box
- Homomorphic encryption technology learning
- 世界读书日:我想推荐这几本书
- [csnote] ER diagram
- Van uploader upload picture implementation process, using native input to upload pictures
- The El table horizontal scroll bar is fixed at the bottom of the visual window
- How to prevent the website from being hacked and tampered with
- 98. Error s.e.errormvcautoconfiguration $staticview reported by freemaker framework: cannot render error page for request
猜你喜欢
Can I take the CPDA data analyst certificate for 0 foundation
box-sizing
Fashion cloud learning - input attribute summary
leetcode:437. 路径总和 III【dfs 选还是不选?】
Number of nodes of complete binary tree
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.
将新增和编辑的数据同步更新到列表
leetcode:437. Path sum III [DFS selected or not selected?]
ZigBee CC2530 minimum system and register configuration (1)
教你快速开发一个 狼人杀微信小程序(附源码)
随机推荐
【蓝桥杯】4月17日省赛刷题训练(前3道题)
Teach you to quickly develop a werewolf killing wechat applet (with source code)
[wechat applet] Z-index is invalid
Deploying MySQL in cloud native kubesphere
Fashion cloud learning - input attribute summary
BUUCTF WEB [BJDCTF2020]ZJCTF,不过如此
22. Bracket generation
Unlock openharmony technology day! The annual event is about to open!
Customize the shortcut options in El date picker, and dynamically set the disabled date
Kubernets Getting started tutoriel
0基础可以考CPDA数据分析师证书吗
梳理網絡IP代理的幾大用途
Luogu p3236 [hnoi2014] picture frame solution
Buuctf Web [gxyctf2019] no dolls
Keyword interpretation and some APIs in RT thread
大家帮我看一下这是啥情况,MySQL5.5的。谢了
mysql支持ip访问
风尚云网学习-h5的input:type属性的image属性
STM32 is connected to the motor drive, the DuPont line supplies power, and then the back burning problem
What are the forms of attack and tampering on the home page of the website