Closed Thread
Results 1 to 2 of 2

Thread: need some help

  1. #1
    debug is offline Newbie
    Join Date
    Aug 2007
    Posts
    17
    Rep Power
    0

    need some help

    import java.util.*;
    public class puzzle{
    final static int MAX_ROW = 8;
    final static int MAX_COL = 4;
    static int numRow;
    static int grid[][] = new int[MAX_ROW][MAX_COL];
    public static void main(String[] args){
    System.out.println(" Enter the number of row:");
    Scanner myScanner = new Scanner(System.in);
    numRow = myScanner.nextInt();
    for(int i = 0; i < numRow; i++)
    {
    for (int j = 0; j < MAX_COL; j++)
    {
    System.out.print(grid[i][j]);
    }
    System.out.println();
    }
    }
    }
    m writing a code to display the tic-tae-toe board but when i run the code the display show only 0 . Can someone help me which part of my code went wrong?? thkx in advance.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    gszauer's Avatar
    gszauer is offline Programmer
    Join Date
    Nov 2007
    Location
    Florida
    Posts
    113
    Rep Power
    16

    Re: need some help

    You have nothing to turnicate one row, and start the second.
    Do this
    import java.util.*;

    Code:
    public class puzzle{
      final static int MAX_ROW = 8;
      final static int MAX_COL = 4;
      static int numRow;
      static int grid[][] = new int[MAX_ROW][MAX_COL];
      public static void main(String[] args){
        System.out.println(" Enter the number of row:");
        Scanner myScanner = new Scanner(System.in);
        numRow = myScanner.nextInt();
        for(int i = 0; i < numRow; i++)    {
          for (int j = 0; j < MAX_COL; j++)    {
            System.out.print(grid[i][j]);
          }
          System.out.print("\n");
        }
        System.out.println();
      }
    }
    Quote Originally Posted by ~Aristotle
    It is the mark of an educated mind to entertain a tought without accepting it
    If my post was helpful, please help me build some rep

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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