converted into programming languageint[] x = new int[10];
for(int i = 0; i < x.length; x[i] = i++);
int[] y = new int[8];
Random random = new Random();for(int i = 0; i < y.length;){
long startTime = System.currentTimeMillis();
long endTime = startTime + random.nextLong();
int index = 0;
do{
index += random.nextInt();
index %= 10;
}while(System.currentTimeMillis() < endTime);
if(x[index] == -1) continue;
y[i++] = x[index];
x[index] = -1;
}Arrays.sort(y);
for(int i = 0; i < y.length; System.out.print(y[i]++ + ", "));
for(int i = 0; i < x.length; x[i] = i++);
int[] y = new int[8];
Random random = new Random();for(int i = 0; i < y.length;){
long startTime = System.currentTimeMillis();
long endTime = startTime + random.nextLong();
int index = 0;
do{
index += random.nextInt();
index %= 10;
}while(System.currentTimeMillis() < endTime);
if(x[index] == -1) continue;
y[i++] = x[index];
x[index] = -1;
}Arrays.sort(y);
for(int i = 0; i < y.length; System.out.print(y[i]++ + ", "));
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货