Magicbox 2

Magicbox 2

how to build this?

import java.util.*; class magicbox{ public static void main(String args[]){ Random r=new Random(); int[][] magic=new int[3][3];

    int temp=r.nextInt(9)+1;
    boolean tempExist=false;

    boolean zeroExist=false;

    while(zeroExist){
        zeroExist=false;

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            int magic=r.nextInt(9)+1;
        }
    }

    L1: for(int a=0;a<3;a++){
                for(int b=0;b<3;b++){
                    if(magic[a][b]==temp){
                        tempExist=true;
                        break L1;
                    }
                }
            }
            if(!tempExist){
                magic[i][j]=temp;
            }
        }
    }





    //break zeros
    L2: for(int x=0;x<3;x++){
            for(int y=0;y<3;y++){
                if(magic[x][y]==0){
                    zeroExist=true;
                    break L2;
                } 
            }
        }
        //print
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            System.out.print(magic[i][j]+" ");
        }
        System.out.println();
    }

}

}

View Answers

December 3, 2012 at 7:56 PM

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)
        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(a[i][j]+" ");
                    }
            System.out.println();
        }
    }
}

}









Related Tutorials/Questions & Answers:
Magicbox 2
Magicbox 2  how to build this? import java.util.*; class magicbox...; } } } } 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 &&
ModuleNotFoundError: No module named 'magicbox'
ModuleNotFoundError: No module named 'magicbox'  Hi, My Python... 'magicbox' How to remove the ModuleNotFoundError: No module named 'magicbox... to install padas library. You can install magicbox python with following
Advertisements
magicbox
use is of 2
use is of 2  why we use 2 in "Integer.parseInt(str,2);" for binary to decimal conversion..??   ya i got it... because binary contain only two o and 1...so here use 2...same as octal has 8
Struts 2
Struts 2  we can extend DispatchAction class to implement a common session validation in struts 1.x. how to do the same in the struts2
Struts 2
Struts 2   I am just new to struts 2 and need to do the task. I have a requirement like this : when i click on link like Customer , this will display all the customers , address from a database table using jdbc and the screen
Struts 2
Struts 2  I am getting the following error.pls help me out. The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has
new 2
new 2  <%@page import="java.util.ArrayList"%> <%@page...; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2 sevelet @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2 import java.io.IOException; import java.io.PrintWriter; import
Echo 2
Echo 2       Echo 2 allows you to code Ajax apps in pure Java (Demo)which automatically generates HTML and Javascript. Read full DescriptionADS_TO_REPLACE_1
FireFox 2
FireFox 2       The award... to do on the Web, and Firefox 2 is full of helpful features to make your... Add-ons that enhance Firefox. It?s easy to personalize Firefox 2
Thunderbird 2
Thunderbird 2       Mozilla?s Thunderbird 2 email application is more powerful than ever. It?s now... Information Organized Thunderbird 2 features many new enhancements to help
Struts 2 - Validation - Struts
Struts 2 - Validation annotations  digging for a simple struts 2 validation annotations example
regarding struts 2
regarding struts 2   is it not possible to get values from applicationresources.properties into our application in struts 2
struts 2 testing
struts 2 testing  can i get an example for struts 2 action class unit test
2's Complement
2's Complement  hi Can anyone plsss tell me the 2's complement java program... Thanks in advance
Where to learn Struts 2?
Where to learn Struts 2?  Hi, I am beginner in Struts and trying to find good tutorial to learn Struts 2 framework. My project is in Struts 2 and soon I have to work on the project. Let's know where to learn the Struts 2
Struts 2 Video Tutorial
Struts 2 Video Tutorial  I think its easy to learn from Struts 2 Video Tutorial. What is the url of Struts 2 Video Tutorial on roseindia.net website... your are right. You can learn Struts 2 very easily with the Struts 2 Video
Struts 2 online tutorial
Struts 2 online tutorial  Where to learn struts 2 online tutorial? Is there any good tutorials on roseindia.net for learning struts 2 online tutorial?   Yes, We have many tutorials for learning Struts 2 online through
Struts 2 + hibernate
Struts 2 + hibernate  How to integrate Struts 2 and Hibernate? Its urgent please help!!   See the example give below.. for integrating struts 2 and hibernate. Struts2.2.1 and hibernate integration application Integrate
What is Struts 2 framework
What is Struts 2 framework  Hi, I am new to the Java web programming. I have completed JSP, Servlet and HTML. Now I want to learn Struts 2. Tell me what is Struts 2? Thanks
Strurt 2 TLD - WebSevices
Strurt 2 TLD  pls any one can send me either link to download or actual TLD files of struts 2 i nead the TLD files but i could not found
struts 2 project samples
struts 2 project samples  please forward struts 2 sample projects like hotel management system. i've done with general login application and all. Ur answers are appreciated. Thanks in advance Raneesh
Struts 2 + Hibernate
Struts 2 + Hibernate  From where can i get good tutorial from integrating struts 2 with hibernate , which explains step by step procedure in integration and to build web applications
struts 2 tabbedpanel - Struts
struts 2 tabbedpanel  Hi Friend do I change the background color of a tab? bye bye
Query Question 2
Query Question 2  Want to displays the name and ID of all departments with the names of the employees in that department. SELECT * FROM employee is my result
Maven 2 - Maven
Maven 2   Hi, I m new to Maven 2 and in process to implement Maven2. I have browse in the net and got my Maven 2 installed but now I m facing few concerns on creating a small project. Please help me in this regard Thanks
Compare 2 files
Compare 2 files  I would like to compare 2 files in Java. please send me the code snipt for this scenario: File1... file 1 and 2. The file name will normally be the last 16 characters of a line
Printing 2 arrays
Printing 2 arrays  Hi, I have 2 arrays: String [] head = {"Name... want this 2 arrays to be printed out in the following manner: head[0] tab personal[0] head[1] tab personal[1] head[2] tab personal [2] I tried different
struts 2 mysql
struts 2 mysql  In the example : http://www.roseindia.net/struts/struts2/struts-2-mysql.shtml how is the username and password(in insertdata.jsp) which is entered by the user is transferred to the { ("INSERT employee VALUES
zend framework 2
zend framework 2  i am new in zf2 and i want to develop a website in zf2 so can anyone help me to figure out the(login and signup page) with database
Struts 2 - Beganner
Struts 2 - Beganner  Hi ! I am new to Struts2 and I need clarification over Difference between Action Proxy and Action Mapper in struts2 and When both perform their activity?????? Many Thanks Venkateshlu
Regarding 2 windows
Regarding 2 windows  Hi, I want 2 separate windows,when i click on a 1st window submit btn then it will show 2nd window. In 2nd window i want 1 textbox.i entered some text on that text box and when i close the 2nd window
session maintain in struts 2
session maintain in struts 2  hi i am new to Struts 2..... in Action class i wrote **HttpSession session = request.getSession(); session.setAttribute("name", name1);** but in jsp class String session_name=(String
Divide 2 numbers
Divide 2 numbers  Write a java program to divide 2 numbers. Avoid division by zeor by catching the exception.   class Divide { public static void main(String[] args) { try{ int num1=8
Struts 2 Tutorial
Struts 2 Tutorial  Hi, Iââ?¬â?¢m taking your Struts 2 Tutorial at http://www.roseindia.net/struts/struts2/struts-2-hello-world-files.shtml. When I open http://localhost:8080/struts2tutorial/ under ââ?¬Å?Testing Struts 2 Hello
Pagination in struts 2
Pagination in struts 2  Hi, I have one question regarding pagination in struts 2 I saw one of your code that you explain here:- http... me or guide me what other option i have to use pagination in struts 2 without
task 2 - Java Beginners
task 2  Write a time server that follows the time protocol outlined in RFC 868. When a client connects, the server sends a 4-byte, big-endian, unsigned integer specifying the number of seconds that have passed since 12:00 A.M.
Struts 2 problem - Struts
Struts 2 problem  Hello I have a very strange problem. I have an application that we developed in JAVA and the application works ok in Windows... seemed to worked fine, until the user reported to us a problem. After doing
java code 1 of 2
java code 1 of 2  Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes   Hi Friend, Visit
address1 and address 2 validation
address1 and address 2 validation  Hi sir/Madam, I m doing One Project Quite now. I would like to validate address that comprises of door numbers,street name, area name .Please provide java-script to do the same.Thanks in advance
tensorflow 2 course
tensorflow 2 course  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: tensorflow 2 course... the topic "tensorflow 2 course". Also tell me which is the good training
coursera tensorflow 2
coursera tensorflow 2  Hi, I am beginner in Data Science and machine... tensorflow 2 Try to provide me good examples or tutorials links so that I can learn the topic "coursera tensorflow 2". Also tell me which is the good
udacity tensorflow 2
udacity tensorflow 2  Hi, I am beginner in Data Science and machine... 2 Try to provide me good examples or tutorials links so that I can learn the topic "udacity tensorflow 2". Also tell me which is the good training
tensorflow 2 udacity
tensorflow 2 udacity  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: tensorflow 2... the topic "tensorflow 2 udacity". Also tell me which is the good training
help me 2
help me 2  write java program to enter five numbers and will determine the location of the number sample output: ENTER 5 NUMBERS: 1 2 3 4 5 ENTER NUMBER TO SEARCH:1{press enter} 1 found in index 0   import
tiles 2 with struts2 - Struts
tiles 2 with struts2   i wnat any one to guide me : how can i integrate struts2 with tiles2 i searched for long time on the web i see many code and configurations but every one of them has a problem can any one give me  
Struts 2 Radio Button
Struts 2 Radio Button  I have a search functionlaity where i have two radio buttons and I am using Struts2 tag.I want first rado button to be selected by default.But when i select the second radio button and hit on search
Moire Pattern 2 Java
Moire Pattern 2 Java   textWhat you are seeing in the screenshot...; g2.setColor(Color.black);g2.fillOval(centerX, centerY - ovalWidth / 2, 300, ovalWidth... - ovalWidth / 2, 300, ovalWidth);g2.rotate(Math.toRadians(15),centerX,centerY
Struts 2 + Ajax
Struts 2 + Ajax  hi , i am new in java ,i need a help I am setting the attribute in by session.setAttribute which is passes values to a jsp page, in which i have used display:column tag ,now the problem is that i have a attribute
que 2 - Java Beginners
que 2  WAP to input a string & print out the text withthe uppercase & lowercase letters reversed,but all other characters should remain the same. eg: input:WelComE TO School output:wELcOMe to sCHOOL  Hi Friend

Ads