当前位置:网站首页>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
边栏推荐
- leetcode:437. 路径总和 III【dfs 选还是不选?】
- 【每日一题】棋盘问题
- Object. The disorder of key value array after keys
- Number of nodes of complete binary tree
- 22. Bracket generation
- Record a website for querying compatibility, string Replaceall() compatibility error
- SSL certificate refund instructions
- 使用Source Insight查看编辑源代码
- [vulnhub range] - DC2
- Web17 -- use of El and JSTL
猜你喜欢
CVPR 2022 & ntire 2022 | the first transformer for hyperspectral image reconstruction
0基础可以考CPDA数据分析师证书吗
mysql中 innoDB执行过程分析
免费试用一个月的服务器,并附上教程
大家帮我看一下这是啥情况,MySQL5.5的。谢了
Mysql8 installation
Free and open source agricultural Internet of things cloud platform (version: 3.0.1)
[vulnhub range] - DC2
风尚云网学习-input属性总结
ZigBee CC2530 minimum system and register configuration (1)
随机推荐
梳理網絡IP代理的幾大用途
网站首页文件被攻击篡改的形式有哪些
Record a website for querying compatibility, string Replaceall() compatibility error
Remote sensing image classification and recognition system based on convolutional neural network
SSL certificate refund instructions
CGC: contractual graph clustering for community detection and tracking
Kubernetes 入門教程
Date time type in database
Web17 -- use of El and JSTL
unity常见的问题(一)
leetcode-791. 自定义字符串排序
Object. The disorder of key value array after keys
21 天学习MongoDB笔记
Can I take the CPDA data analyst certificate for 0 foundation
What are the forms of attack and tampering on the home page of the website
Luogu p3236 [hnoi2014] picture frame solution
Recommended website for drawing result map
[vulnhub range] - DC2
Customize the shortcut options in El date picker, and dynamically set the disabled date
Packet capturing and sorting -- TCP protocol [8]