展开全部
你好,提问者:
如果解决了你的问题,请采纳,若有疑62616964757a686964616fe58685e5aeb931333366303861问请追问,谢谢!package com.zyx.cn.baidu_exam;
import java.util.Scanner;
/**
* 输入5个整数,并查找出指定的整数位置
* @author yltd
*/
public class ChaZhao {
public static void main(String[] args) {
int[] arr =new int[5];
Scanner sc =new Scanner(System.in);
for (int i = 1; i <= 5; i++) {
System.out.print("请输入第"+i+"个整数:");
int number = sc.nextInt();
arr[i-1] = number;
}
System.out.println("查找数组是否存在这个整数:");
int num = sc.nextInt();
for (int i = 0; i
if(num == arr[i]){
System.out.println(num+":在数组中的下标:"+i);
}
}
}
}结果:
请输入第1个整数:10
请输入第2个整数:60
请输入第3个整数:70
请输入第4个整数:80
请输入第5个整数:90
查找数组是否存在这个整数:
80
80:在数组中的下标:3