HW6.10

HW6.10

 import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);
         double[] number = new double[10];

         System.out.print("Enter 10 numbers: ");
         for(int i = 0; i < 10; i++)
             number[i] = input.nextDouble();

         input.close();

         System.out.println("The index of the minimum element is " + indexOfSmallestElement(number));
     }

     public static int indexOfSmallestElement(double[] array)
     {
         double minValue = Double.MAX_VALUE;
         int index = 0;
         for(int i = 0; i < array.length; i++)
             if(array[i] < minValue)
             {
                 minValue = array[i];
                 index = i;
             }
         return index;
     }
 }
上一篇:好的android编码习惯


下一篇:mui-popover显示、隐藏弹出菜单的方法