1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
import java.util.*;
public class another
{
public static void main(String[] arguments)
{
int number[] = { 1,3,7,8,10,13,17,18,19,20,23,24,26,
27,29,32,33,35,39,41,43,46,47,48,49,50 };
int [] order = new int[number.length];
System.out.println("The original order:");
for (int i = 0; i < number.length; i++){
order[i] = i;
System.out.println(i + ": " + number[i]);
}
System.out.println("The new order:");
int orderLen = number.length;
for (int i = 0; i < number.length; i++)
{
int index = (int) (Math.random() * orderLen);
int pos = order[index];
System.out.println(pos + ": " + number[pos]);
order[index] = order[--orderLen];
}
int min = 0;
int max = number.length;
int res;
for(int j=0; j < 5 ; j++)
System.out.println("Number"+ (j+1) + (int)(Math.random()*number));
}
} |
Partager