62,614
社区成员
发帖
与我相关
我的任务
分享
import java.util.*;
class t1
{
public static void main(String[] args)
{
Object[][][] ojb1 = new Object[10][5][9];
Object[][][] ojb2 = new Object[7][5][9];
Object[][][] ojb3 = new Object[6][5][9];
int total = 0;
int count = 0;
for(int i=0; i<104; i++ ){
while(count < 100){
int x = (int) (Math.random() * 5);
int y = (int) (Math.random() * 9);
int z = (int) (Math.random() * 10);
int m = (int) (Math.random() * 7);
int n = (int) (Math.random() * 6);
if(ojb1[z][x][y] == null && ojb1[m][x][y] == null && ojb3[n][x][y] == null){
ojb1[z][x][y] = new String("No Empty");
ojb1[m][x][y] = new String("No Empty");
ojb1[n][x][y] = new String("No Empty");
System.out.println("Added " + i);
break;
}else{
count+=1;
}
}
if(count >=100){
System.out.println("Conflict " + i);
total +=1;
}
}
System.out.println("Total of conflict: " + total);
}
}