-3
所以我不斷收到這個錯誤信息,我不知道它是什麼意思或如何迴應。繼承人我的代碼。當我去一個不同的編譯器,我沒有得到這個問題。提前致謝!未解決的錯誤在主(Eclipse)
import java.math.*;
import java.util.*;
public class QuestionEight {
public QuestionEight() {
// TODO Auto-generated constructor stub
}
public static void main(String [] args) {
// TODO Auto-generated method stub
int[] newArr = new int[1000];
for(int a = 0; a<1000; a++) {
newArr[a] = countNumbers();
}
double sum = (double)sumOfArray(newArr);
double attempts = (double)1000;
System.out.println("The average is " + sum/attempts);
}
public static int countNumbers() {
int sum = 0;
int counter = 0;
while(sum<1) {
sum = Math.floor(10.0*Math.random());
counter++;
}
return counter;
}
public static int sumOfArray(int[]a) {
int[] tempArr = new int[a.length];
for(int c = 0; c<a.length; c++)
tempArr[c] = a[c];
for(int d = 1; d<a.length; d=d+2) {
tempArr[d] = tempArr[d] + tempArr[d-1];
if(d==tempArr.length-1) {
return tempArr[d];
}
}
return 0;
}
}
是從字面上得到的所有錯誤文本?此外,這是一個奇怪的方式來總結一個數組... –
你是什麼意思是由「不同的編譯器」? –
它在BlueJ工作。是的,那基本上是我得到的所有錯誤文本 –