class TestOrdinaNumeri{
public static void main(String[] args){
int n = 3;
int i[] = new int[n];
i = TestArrayGenera(n);
TestArrayOrdina(i);
TestArrayStampa(i);
}
public static int[] TestArrayGenera(int n){
int temp[] = new int[n];
for(int i=0; i<n; i++){
temp[i] = (int)(Math.random() * 100);
}
return temp;
}
public static void TestArrayOrdina(int[] array){
for (int i = 1; i < array.length; i++){
int j = i;
int B = array[i];
while ((j > 0) && (array[j-1] > B)){
array[j] = array[j-1];
j--;
}
array[j] = B;
}
}
public static void TestArrayStampa(int[] array){
for(int i=0;i<array.length;i++){
System.out.println("i["+i+"] = " + array[i]);
}
}
}