java数组练习---输入10个整数,找出最小的数及其下标

public class Test11 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new  Scanner(System.in);
		int[] arr = new int[10];
		System.out.println("请输入十个整数:");
		for (int i = 0; i < arr.length; i++) {
			arr[i] = sc.nextInt();
		}
		int min= arr[0];
		for (int i = 0; i < arr.length; i++) {
			if(arr[i] < min) {
				min = arr[i];
				System.out.println("最小的数是:" + min);
				System.out.println("该数的下标是:" + i);
			}
		}
		
	}

}

你可能感兴趣的:(JAVA学习之旅)