java的神奇代码
程序员文章站
2022-06-01 20:24:15
...
import java.util.Random;
public class jabckjabc {
/**
* @param args
*/
public static void main(String[] args) {
int[] ina = new int[]{20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39};
Random randoma = new Random();
int mhsochd = 0;
for (int i = 0; i < 20; i++) {
int[] inx = Arraymcq(ina,randoma);
for (int j = 0; j < ina.length; j++) {
if (inx[j]==ina[j]) {
mhsochd += 1;
}
}
}
System.out.println(mhsochd);
}
public static int[] Arraymcq(int[] inz,Random randoma){
int mcq ;
int mcg = inz.length;
int[] inw = new int[inz.length];
for (int i = 0; i < inz.length; i++) {
mcq = (int)(randoma.nextDouble()*mcg);
if (inz[mcq]==-1) {
do {
if (mcq+1 >= mcg) {
mcq = 0;
}else {
mcq=mcq+1;
}
} while (inz[mcq]==-1);
}else {
}
inw[i] = inz[mcq];
inz[mcq]=-1;
}
return inw;
}
}
没看清楚这个代码是什么情况,笑死了!!!!
上一篇: 数据结构中的线性表及其结构
下一篇: 数据结构---线性表的顺序存储结构