欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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;
}

}

java的神奇代码
没看清楚这个代码是什么情况,笑死了!!!!

相关标签: 基础 java