如何打印数组索引/下标

-7 java loops input moving-average

几乎没有Java问题:

  1. 如何提示用户输入?
  2. 如何在数组中保存用户的输入?
  3. 如何平均数组中的数字?
  4. 如何比较数字?
  5. 如何将信息打印回用户?

方案如下:让用户在数组中输入10个数字.然后遍历数组并对其进行平均.然后再次遍历数组并将每个值与平均值进行比较,如果它低于用户输入的10个数字的平均值,则打印数字(和/或循环索引).

Uma*_*nth 5

Read the array.

Calculate the average.

Loop through the array
   check if it has value less than average
        if yes print the index
   if no check for the next
Run Code Online (Sandbox Code Playgroud)