import java.util.Scanner;
public class P2148 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();//学生数目
int k=sc.nextInt();//Lele的学号
int score[]=new int[n+1];
int count=0;
for(int i=1;i<score.length;i++){
score[i]=sc.nextInt();
}
for(int i=1;i<score.length;i++){
if(score[i]>score[k]){
count++;
}
}
System.out.println(count);
}
}
}
public class P2148 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();//学生数目
int k=sc.nextInt();//Lele的学号
int score[]=new int[n+1];
int count=0;
for(int i=1;i<score.length;i++){
score[i]=sc.nextInt();
}
for(int i=1;i<score.length;i++){
if(score[i]>score[k]){
count++;
}
}
System.out.println(count);
}
}
}
本文介绍了一个使用Java编程语言实现的功能,通过输入学生数量和特定学生的学号,程序能够快速找出并打印该学生比其他学生成绩高的次数。
660

被折叠的 条评论
为什么被折叠?



