当前位置:网站首页>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
边栏推荐
- How to click an object to play an animation
- 梳理网络IP代理的几大用途
- SSL certificate refund instructions
- Can I take the CPDA data analyst certificate for 0 foundation
- Jiachen chapter Genesis "inner universe" joint Edition
- BUUCTF WEB [GXYCTF2019]禁止套娃
- BUUCTF WEB [BJDCTF2020]The mystery of ip
- BaseRecyclerViewAdapterHelper 实现下拉刷新和上拉加载
- Use compressorjs to compress pictures, optimize functions, and compress pictures in all formats
- Buuctf Web [gxyctf2019] no dolls
猜你喜欢

SSM框架系列——数据源配置day2-1

31. 下一个排列

mysql8安装

Bert base Chinese Download (SMART)
![[unity note] basic lighting in l4unity](/img/38/d88245af2062ed67fb8e61327f3bb9.png)
[unity note] basic lighting in l4unity

Sort out several uses of network IP agent

CVPR 2022 & ntire 2022 | the first transformer for hyperspectral image reconstruction

Teach you to quickly develop a werewolf killing wechat applet (with source code)

22. Bracket generation

NPDP|产品经理如何做到不会被程序员排斥?
随机推荐
mysql支持ip访问
[Blue Bridge Cup] April 17 provincial competition brushing training (the first three questions)
Packet capturing and sorting -- TCP protocol [8]
Zero trust in network information security
将新增和编辑的数据同步更新到列表
The El table horizontal scroll bar is fixed at the bottom of the visual window
Teach you to quickly develop a werewolf killing wechat applet (with source code)
mysql8安装
leetcode-791. 自定义字符串排序
只是不断地建构平台,不断地收拢流量,并不能够做好产业互联网
Plato Farm-以柏拉图为目标的农场元宇宙游戏
BUUCTF WEB [BUUCTF 2018]Online Tool
CVPR 2022 & ntire 2022 | the first transformer for hyperspectral image reconstruction
如何防止网站被黑客入侵篡改
Web17 -- use of El and JSTL
XinChaCha Trust SSL Organization Validated
如何实现点击一下物体播放一次动画
风尚云网学习-h5的input:type属性的image属性
Deploying MySQL in cloud native kubesphere
Buuctf Web [gxyctf2019] no dolls