0
的陣列我試圖使這個程序找到一個隨機生成的10個號碼
public class Statistics {
public static void main(String[] args) {
final int SIZE = 10;
int sum =0;
int[] numArray= new int [SIZE];
for (int c=0; c < SIZE; c++)
{
numArray[c]=(int)(Math.random()*6+1);
System.out.print(numArray[c]+ " ");
sum+=numArray[c];
}
System.out.println("\nSum of all numbers is " + sum);
System.out.println("\n Mean of numbers is " + (sum)/5);
}
}
計算隨機生成的陣列的模式的模式。
我見過發佈源代碼的地方,他們使用一個單獨的方法稱爲computemode,但我不知道在哪裏把第二個方法放在我的代碼中。對不起,在編程方面我非常非常環保。我被教授Java作爲第一語言,到目前爲止它是壓倒性的。
如果有人可以發佈詳細的說明/解釋語法,我會很感激。
一個數組可以有多個模式。你需要報告數組中有最大頻率的所有值還是隻有一個?你需要報告地點嗎? – 2012-03-16 21:06:42