
i want help to complete this program.
import java.util.*; class Mgic2{
public static void main(String []args){
Random r=new Random();
int [][] magic=new int[3][3];
boolean v15=true;
while(v15){
int [][]a;
a=new int [3][3];
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
boolean tempexsist=true;
L1:while(tempexsist){
int temp=r.nextInt(9)+1;
for(int k=0;k<3;k++){
for(int l=0;l<3;l++){
if(a[k][l]==temp)
continue L1;
}
}
tempexsist=false;
if(!tempexsist){
a[i][j]=temp;
}
}
}
}
v15=a[0][0]+a[0][1]+a[0][2]==15 &&
a[1][0]+a[1][1]+a[1][2]==15 &&
a[2][0]+a[2][1]+a[2][2]==15 &&
a[0][0]+a[1][0]+a[2][0]==15 &&
a[0][1]+a[1][1]+a[2][1]==15 &&
a[0][2]+a[1][2]+a[2][2]==15 &&
a[0][0]+a[1][1]+a[2][2]==15 &&
a[0][2]+a[1][1]+a[2][0]==15 ;
v15=!v15;
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
System.out.print(magic[i][j]+" ");
}
System.out.println();
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.