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.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();
}
}
}
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(); } }
If my post was helpful, please help me build some repOriginally Posted by ~Aristotle
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks