我需要编写一个方法FillPinDouble
,它将使用Math.sqrt()填充一个名为doublepin的数组,其值为√n,√n-1,√n-2,..,√1。 / p>
在我的main方法中,我应该调用此方法来填充doublepin arr。我应该打印一次数组,然后再反复打印。例如,如果我的数组是[2,8,16,9]那么它应该打印为[9,16,8,2]。这就是我到目前为止所做的:
public static double FillPinDouble()
{
double n;
double[] doublepin=new double[n];
for(i=0;i<n;i++) // i wonder about ... on the √n,√n-1,√n-2,..,√1 how much would it be.The number 6 i chose it 5 slots are for sure in the array.= but may need more
{
double m=(double) (Math.random() * 101) // i try to use math random for
creating √n,√n-1,√n-2,..,√1 .I cant figure out how can i be this
doublepin[1]=√n
doublepin[2]=√n-1
doublepin[3]=√n-2
doublepin[4]=√1 // may needs and other slots double[5],[6],[7],..
}
System.out.println([i]);
return doublepin[i]; // return the double array
}//end method
在我的主要方法中,我会这样称呼:
double x; // i did this to save the method(the array)
x=Klashkalw.FillPinDouble(); // i call the method and i save it to x.
System.out.println(x); //i dont know after how i change from last to the beggining i may have mistakes because i try to do something is unknowledge for me.
由于