返回列表 發帖
  1. import java.util.Scanner;
  2. public class JPD05 {
  3.    
  4.    
  5.     public static void main(String args[]) {
  6.         Scanner scanner = new Scanner(System.in);
  7.             int[] array = new int[10];
  8.         int n=0,sum=0,temp=1;
  9.         for(int i=0;i<array.length;i++)
  10.         {
  11.                 System.out.print("請輸入第"+temp+"個數");
  12.                 array[i] = scanner.nextInt();
  13.                 if(array[i]>60)
  14.                 {
  15.                         n++;
  16.                         sum+=array[i];
  17.                 }
  18.                 temp++;
  19.         }
  20.         System.out.println("陣列中大於60的有" + n + "個\n總合為" + sum + "\n平均值為" + (sum / (double)n));
  21.     }
  22. }
複製代碼

TOP

返回列表