Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


supun dahanayaka
box +15 2nd
0 Answer(s)      a year and 11 months ago
Posted in : Java Beginners


how to fix this?

import java.util.*;

class Example{

public static void main(String args[]){

Random r=new Random();

     int x[][]=new int[3][3];

     boolean b1=false,b2=false;

        L1:while(b2==false){

               for(int a=0;a<3;a++){

                  for(int b=0;b<3;b++){

                     int y =r.nextInt(9)+1;

                        for(int i=0;i<=a;i++){

                              for(int j=0;j<3;j++){

                                      if(x[i][j]==y){

                                             y =r.nextInt(9)+1;

                                             i=0;

                                             j=-1;

                                             b1=false;

                                      }else{

                                             b1=true;

         }

       }

}

if(b1==true){

x[a][b]=y;

}

}

} for(int i=0;i<3;i++){

int t1=0,t2=0;

for(int j=0;j<3;j++){

t1+=x[i][j];

t2+=x[j][i];

}

if(!(t1==15 && t2==15)){

continue L1;

}

}

if(x[0][0]+x[1][1]+x[2][2]==15 && x[2][0]+x[1][1]+x[0][2]==15){

b2=true;

}else{

continue;

}

}

//Print

for(int i[]:x){

for(int j:i){

System.out.print(j+" ");

}

System.out.println();

}

}

}


Advertisement
View Answers

Related Tutorials/Questions & Answers:
box +15 2nd
box +15 2nd  how to fix this? import java.util.*; class Example...; for(int j=0;j<3;j++){ t1+=x[i][j]; t2+=x[j][i]; } if(!(t1==15 && t2==15)){ continue L1; } } if(x[0][0]+x[1][1]+x[2][2]==15 && x[2][0
box +15
box +15  i want help to complete this program. import java.util....; } } } } 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 &&
Advertisements
15 Php programs on logical operators
15 Php programs on logical operators  I need 15 example programs for logical operators. Please help me out
in an application one task has to done for every 15 minutes ? How con you do it?
in an application one task has to done for every 15 minutes ? How con you do it?  in an application one task has to done for every 15 minutes ? How con you do
Display the Shadow of the string
GradientPaint to draw a box. The g.setStroke(new BasicStroke(15)) draw the wide lines...(paint);   g2d.translate(15, 20);   g2d.fill(affineTransform.createTransformedShape(h));   g2d.translate(-15, -20
Annotation
Annotation       Annotation is one more powerful feature of Java, an object-oriented programming language included in JDK 1.5. Annotations were introduced in September 2004
Using Youtube as a Social Media Marketing
Using Youtube as a Social Media Marketing Tool Youtube is the largest video upload and play site in the world, with more than 20 million subscribers and more than 15 million people visiting the site, making it a great medium for any
railway reservation
application in jframe connectivity with sql server. i need a help in jcombo box in my program, when i select train number in jcombo box in other combo box..., sat","1st A.c, 2nd A.c, 3rd A.c","1500,900,750,","800 k.m"}, {"04116
railway reservation
application in jframe connectivity with sql server. i need a help in jcombo box in my program, when i select train number in jcombo box in other combo box..., sat","1st A.c, 2nd A.c, 3rd A.c","1500,900,750,","800 k.m"}, {"04116
Programming error - JSP-Servlet
that the user has input in place_ad Eg:3(from count box) then it should... me thankyou. 1)classified Text:if there 15 words then cost is Rs:650 and more than 15 that is per word cost is Rs:30 2)classified Display:for 15 words
Create Before Insert Trigger in SQL
int,Stu_Name Varchar(15),Sub1 int,Sub2 int,Sub3 int, Sub4 int,Sub5 int,total int,per float,status varchar(15)); Create Trigger Stu_Insert Now, we...;; elseif new.per>=45 and new.per<60 then set new.status="2nd
Create Before Insert Trigger in SQL
int,Stu_Name Varchar(15),Sub1 int,Sub2 int,Sub3 int, Sub4 int,Sub5 int,total int,per float,status varchar(15)); Create Trigger Stu_Insert... new.status="2nd Div"; else set new.status="1st Div"
Create Before Update Trigger in SQL
int,Stu_Name Varchar(15),Sub1 int,Sub2 int,Sub3 int, Sub4 int,Sub5 int,total int,per float,status varchar(15)); Create Trigger Stu_Insert...;; elseif new.per>=45 and new.per<60 then set new.status="2nd
Create Before Update Trigger in SQL
_Name Varchar(15),Sub1 int,Sub2 int,Sub3 int, Sub4 int,Sub5 int,total int,per float,status varchar(15)); Create Trigger Stu_Insert The Before... new.status="2nd Div"; else set new.status="1st Div"
Java swing - Java Beginners
Java swing  I created a text box and a button. When clicking a button a message have to come like "welcome then the thing i entered in the text box... JTextField text=new JTextField(15); JButton button=new JButton("Submit"); JFrame
Combobox program - Java Beginners
(null); JLabel lbl1 = new JLabel("Name"); JTextField jt1=new JTextField(15); JLabel lbl2 = new JLabel("Age"); JTextField jt2=new JTextField(15); JLabel lbl3... in combobox a new text box have to open beside that combo box..  Hi
SQL AND Operators
. 1st Condition 2nd Condition Result false... varchar(15), Stu_Class varchar(10)) Insert data into Stu_Table
SQL OR Operators
. 1st Condition 2nd Condition Result false... table Stu_Table(Stu_Id integer(2), Stu_Name varchar(15), Stu_Class varchar(10
SQL AND Operators
. 1st Condition 2nd Condition Result false... varchar(15), Stu_Class varchar(10)) Insert data into Stu_Table
SQL OR Operators
. 1st Condition 2nd Condition Result false... table Stu_Table(Stu_Id integer(2), Stu_Name varchar(15), Stu_Class varchar(10
Simple Text display
to display any text in a text input box using a button click. It is very simple... that flex panel we have to use a button and a textinput box which are present...;text1.text='howdy'" x="15" y="50"/>   </mx
chocolate manufacturing
bars ,chocolate powder ,chocolate gift box and chocolate tins/packets... is based on the size. Category Price 10 gms 10 rs 20 gms 14 rs 30 gms 15 rs 50 gms 18 rs 100 gms 25 rs 200 gms 30 rs There is a gift box option provided
case study
rs 30 gms 15 rs 50 gms 18 rs 100 gms 25 rs 200 gms 30 rs There is a gift box... products like- chocolate bars ,chocolate powder ,chocolate gift box and chocolate.... The gift box has a flat price of rs 200. The company 's another product
java button - Java Beginners
CheckBoxForm extends JApplet { JTextArea t = new JTextArea(6, 15); private JCheckBox cb1 = new JCheckBox("Check Box 1"); private JCheckBox cb2 = new JCheckBox("Check Box 2"); private JCheckBox cb3 = new JCheckBox("Check Box 3
On HTML and JavaScript - Java Beginners
to select a month from selectbox I want the default value of select box to be select but when user select the box for options then there should not be option called... slection box using in javaScript Select Date and month using
Hide boxes by clicking on it using jQuery
example , 30 boxes inside web page are displayed. When we click on any box (among these 30 boxes), it  disappears and the next box (if any) shifts to left...; Description of the program : Inside "div" ,box is created using '
JavaScript createAttribute method
and Add attribute button it sets the text box size to 15 by removing the default... have created an attribute "size" and set its value to the "15"... = document.createAttribute("size"); attribute.nodeValue = "15"
contructors 1&test
created with length 10 and width 15. Box created with length 1, width 2...contructors 1&test   how do i Create a class named Box that includes.... This constructor should also print a line of text that says, "Box created with length
Shortest path in JSP for a given source and destination
','Kanchipuram',5), (4,'Kanchipuram','Arani',15), (5,'Arani','Arcot',20), (6... want to do this in JSP. I have to get the source and destination in text box
Shortest path in JSP for a given source and destination
,'Chennai','Kanchipuram',5), (4,'Kanchipuram','Arani',15), (5,'Arani','Arcot',20), (6... box in one HTML page. and forward that to one JSP page and I have to do
jdk 1.6 vs jdk 1.7
: 1)Java 1.6 runs faster than Java 1.5. 2)Java 1.6 makes programming easier...-of-the-box benefits without any coding changes or even a re-compile necessary. 6)Java
Advertisements
 

 

 

DMCA.com