0
需要將中間值和標準偏差添加到以下程序中,但我不知道從哪裏開始,我知道我想要它做什麼,但不知道如何使它發生,尤其是因爲中位數必須在排序後的數字後面,但如果我把它作爲void Median(),我會丟失排序後的數組。請幫忙!任何幫助是非常讚賞:Java Array標準偏差和中位數
import java.util.Scanner;
import javax.swing.*;
public class JScannerO
{
public JScannerO(){}
public JScannerO(int A)
{
HowMuch = A;
}
void GenerateNumbers()
{
int k,Hide;
k = 0;
while (k < HowMuch)
{
Hide = (int) (Math.random() * 100);
if (Hide > 9 && Hide < 100)
{
Hanson[k] = Hide;
k++;
}
}
}
void DisplayNumbers()
{
int k;
for (k = 0; k < HowMuch; k++)
{
System.out.println("\t\tThe numbers are : " + Hanson[k]);
}
}
void BiggestNumber()
{
int k,Biggest;
Biggest = Hanson[0];
for (k = 0; k < HowMuch; k++)
{
if (Biggest < Hanson[k]) Biggest = Hanson[k];
}
System.out.println("\n\n\t\tThe biggest number is : " + Biggest);
}
void SmallestNumber()
{
int k,Smallest;
Smallest = Hanson[0];
for (k = 0; k < HowMuch; k++)
{
if (Smallest > Hanson[k]) Smallest = Hanson[k];
}
System.out.println("\n\n\t\tThe Smallest number is : " + Smallest);
}
void Average()
{
int k,Sum;
double Average;
Sum = 0;
for (k = 0; k < HowMuch; k++)
{
Sum = Sum + Hanson[k];
}
Average = 1.0 * Sum/HowMuch;
System.out.format("\n\n\t\tThe Average number is : %7.2f",Average);
}
void Sort()
{
int k,Hide;
boolean DidISwap;
DidISwap = true;
while (DidISwap)
{
DidISwap = false;
for (k = 0; k < HowMuch - 1; k++)
{
if (Hanson[k] > Hanson[k+1])
{
Hide = Hanson[k ];
Hanson[k] = Hanson[k+1];
Hanson[k+1] = Hide ;
DidISwap = true;
}
}
}
System.out.println("\n\n\n\t\tThe Sorted Numbers : \n");
}
private int HowMuch;
private int[] Hanson = new int[100];
}
這是通過調用程序
請編輯您的問題,並注意[格式幫助] (http://stackoverflow.com/editing-help)。 –
你是什麼意思,你失去陣列?如果你的數組是排序的,你的中位數就是array [array.length/2],如果長度是奇數,並且數組[array.length/2]和array [array.length/2 + 1]的平均值是否爲 –
Do我在void Sort()下面嵌套以保持排序的數組?我的印象是,如果我使用void Median(),那麼我必須再次對數字進行排序? – user1775694