Sudoku - import java.util.Scanner; import java.io.*; public...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.Scanner; import java.io.*; public class Sudoku { private int[][] grid; private boolean complete; private int size; public Sudoku(Scanner input) { size = 9; complete = false; grid = new int[size][size]; read(input); } public void read(Scanner input) { for (int r=0; r < size; r++) for (int c=0; c < size; c++) grid[r][c] = input.nextInt(); } public void display(PrintStream output) { String line = ""; for (int i=0; i <= size; i++) line += "--"; for (int r=0; r < size; r++) { for (int c=0; c < size; c++) { output.print(grid[r][c] + " "); output.print("| "); } output.println(); output.println(line); } } public void checkValid(PrintStream output) { // check rows for (int r=0; r < size; r++) { output.print("row " + (r+1) + ": "); output.println(checkGood(grid[r])); } int[] temp; for (int c=0; c < size; c++) { temp = colThing(c); output.print("col " + (c+1) + ": "); output.println(checkGood(temp));
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
} for (int b=0; b < size; b++)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/03/2010 for the course COMPSCI 600.107 taught by Professor Houlahan during the Spring '08 term at Johns Hopkins.

Page1 / 3

Sudoku - import java.util.Scanner; import java.io.*; public...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online