Home Article Practice 顺序排序(输入一个数有输出下标,没有输出不存在)

顺序排序(输入一个数有输出下标,没有输出不存在)

2021-07-25 14:52  views:1026  source:135792468    

public static void main(String args[]){
int a[]={1,5,6,9,8};
Scanner scan = new Scanner(System.in);
int b = scan.nextInt();
int i = 0;
for(;i<a.length;i++){
if(b == a[i]){
System.out.println("第"+i+"位");
break;
}
}
if(i == a.length){
System.out.println("不存在");
}
}



Disclaimer: The above articles are added by users themselves and are only for typing and communication purposes. They do not represent the views of this website, and this website does not assume any legal responsibility. This statement is hereby made! If there is any infringement of your rights, please contact us promptly to delete it.

字符:    改为:
去打字就可以设置个性皮肤啦!(O ^ ~ ^ O)