class Sodu {
public static void main(String[] args){
int a1=2, a3=1,a5=1,a7=2,a9=3,a13=4,a16=2;
for (int a2=1;a2<5 ;a2++ ) {
for (int a4=1;a4<5 ;a4++ ) {
for (int a6=1;a6<5 ;a6++ ) {
for (int a8=1;a8<5 ;a8++ ) {
for (int a10=1;a10<5 ;a10++ ) {
for (int a11=1;a11<5 ;a11++ ) {
for (int a12=1;a12<5 ;a12++ ) {
for (int a14=1;a14<5 ;a14++ ) {
for (int a15=1;a15<5 ;a15++ ) {
int[] x ={1,2,3,4};
int[][] arr = new int[12][4];
arr[0]=new int[]{a1,a2,a3,a4};
arr[1]=new int[]{a5,a6,a7,a8};
arr[2]=new int[]{a9,a10,a11,a12};
arr[3]=new int[]{a13,a14,a15,a16};
arr[4]=new int[]{a1,a2,a5,a6};
arr[5]=new int[]{a3,a4,a7,a8};
arr[6]=new int[]{a9,a10,a13,a14};
arr[7]=new int[]{a11,a12,a15,a16};
arr[8]=new int[]{a1,a5,a9,a13};
arr[9]=new int[]{a2,a6,a10,a14};
arr[10]=new int[]{a3,a7,a11,a15};
arr[11]=new int[]{a4,a8,a12,a16};
for (int i =0;i<=11 ;i++ ) {
if (tell(arr[i],x)) {
if (i==11) {
for (int s =0;s<=3 ;s++ ) {
for (int t =0;t<=3 ;t++ ) {
System.out.print(arr[s][t]+" ");
}
System.out.println("");
}
System.out.println("-----");
}
}
else {
break ;
}
}
}
}
}
}
}
}
}
}
}
}
public static boolean tell(int[] arr, int[] arr1){
int sum =0;
arr1 =new int[]{1,2,3,4};
for (int i =0;i<=3 ;i++ ) {
for (int j =0;j<=3 ;j++ ) {
if (arr[i]==arr1[j]) {
sum++;
arr1[j]= 10;
break;
}
}
}
if (sum==4) {
return true;
}
else {
return false;
}
}
}
|
|