Results 1 to 3 of 3
  1. #1
    seongchog is offline Member
    Join Date
    Sep 2011
    Posts
    11
    Rep Power
    0

    Default Anyone could explain the Code.....

    ================================================== =========
    Not really understand the code anyone could explain for me ....
    ================================================== =========

    Java Code:
    int i, j;
            int a = 0, b = 4;
     
            for (i = 9; i > 0; i-=2) {
     
                System.out.println();
     
                for (j = 0; j<a; j++){
                    System.out.print(" ");
                }
     
                for (j = 0; j < i; j++){
                    System.out.print("*");
                }
               
                a++;
            }
     
            for (i = 0; i < 9; i+=2) {
     
                for (j = 0; j < b; j++){
                    System.out.print(" ");
                }
                if(i!=0){
                    for (j = 0; j <= i; j++){
                        System.out.print("*");
                    }
                }
     
                System.out.println();
                b--;
    ================================================== =========

    ================================================== =========
    Last edited by sunde887; 09-22-2011 at 10:29 PM. Reason: Added code tags, [code]...[/code]

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,965
    Rep Power
    8

    Default Re: Anyone could explain the Code.....

    What don't you understand about it? Have you stepped through it with a debugger? Have you stepped through it with a piece of paper and a pencil?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    seongchog is offline Member
    Join Date
    Sep 2011
    Posts
    11
    Rep Power
    0

    Default Re: Anyone could explain the Code.....

    Java Code:
    int i, j;   <------declare i &j
    int a = 0, b = 4;<-------declare a=0 b=4
    
    for (i = 9; i > 0; i-=2) { < ------ i got 9 rol, i more 0 ,i -=2 
    
    System.out.println();       
    for (j = 0; j<a; j++){
    System.out.print(" ");
    }
    
    for (j = 0; j < i; j++){
    System.out.print("*");
    }
    
    a++;
    }
    
    for (i = 0; i < 9; i+=2) {
    
    for (j = 0; j < b; j++){
    System.out.print(" ");
    }
    if(i!=0){
    for (j = 0; j <= i; j++){
    System.out.print("*");
    }
    }
    
    System.out.println();
    b--;
    Last edited by sunde887; 09-22-2011 at 10:30 PM.

Similar Threads

  1. Any one help me fix JAVA code and explain ?
    By batista11b5 in forum New To Java
    Replies: 4
    Last Post: 10-23-2010, 05:19 PM
  2. Please explain how this bit of code works.
    By Allspark in forum New To Java
    Replies: 4
    Last Post: 09-03-2010, 03:56 AM
  3. Please explain these 2 lines of code to me..
    By murphaph in forum New To Java
    Replies: 10
    Last Post: 01-19-2010, 02:11 PM
  4. how does this code work...explain me the execution please...
    By vital parsley in forum New To Java
    Replies: 3
    Last Post: 07-25-2008, 04:50 AM
  5. need to explain this code
    By reached in forum New To Java
    Replies: 3
    Last Post: 12-03-2007, 10:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •