Click here to Skip to main content
12,752,373 members (40,866 online)
   

Java

 
GeneralRe: programming Pin
quest4knowledge20-Dec-12 7:39
groupquest4knowledge20-Dec-12 7:39 
AnswerRe: programming Pin
April Fans19-Dec-12 17:40
memberApril Fans19-Dec-12 17:40 
GeneralRe: programming Pin
Richard MacCutchan20-Dec-12 0:11
mvpRichard MacCutchan20-Dec-12 0:11 
GeneralRe: programming Pin
quest4knowledge20-Dec-12 7:44
groupquest4knowledge20-Dec-12 7:44 
GeneralRe: programming Pin
April Fans27-Dec-12 4:54
memberApril Fans27-Dec-12 4:54 
QuestionInfix to Prefix, Incorrect output Pin
SamuelSkenzy15-Dec-12 15:19
memberSamuelSkenzy15-Dec-12 15:19 
AnswerRe: Infix to Prefix, Incorrect output Pin
TorstenH.16-Dec-12 20:47
memberTorstenH.16-Dec-12 20:47 
QuestionProblem in scanning from file in Sudoku backtracking Pin
Member 858607213-Dec-12 23:10
memberMember 858607213-Dec-12 23:10 
Hello...I'm writing a sudoku project, which can solve a sudoku table with backtracking algortihm...but when I test the value of "matrix" array by debugging I see that these are not correct....can any body help me?
This is an example of input file :
3 0 0 9 0 0 2 0 0
0 0 5 0 0 0 0 0 7
6 0 0 0 3 0 0 0 8
0 0 0 0 6 1 0 4 0
0 4 0 0 0 0 7 0 0
0 3 6 0 0 0 0 9 0
0 2 7 0 0 0 0 0 0
0 0 0 0 1 0 8 0 5
0 9 0 2 0 8 0 0 0

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package filesudoku;

/**
 *
 * @author ahangari
 */
import java.io.*;
import java.util.*;
import java.lang.Exception;


public class Sudoku {

     public static int[][] matrix;
     public static int counter = 0;
     public static String matrixView;

     public static void main(String[] args)  throws FileNotFoundException{

          System.out.print("Please enter file name: ");
          Scanner in = new Scanner(System.in);
          String fileName = in.next();
          matrixCreate(fileName);

        // TODO code application logic here
    }
 public static void matrixCreate(String fileName) throws FileNotFoundException {

    File getFile = new File(fileName);
    Scanner scan = new Scanner(getFile);
    matrixView = null;

    while (scan.hasNextLine()){
      matrixView = scan.nextLine();//consider each line of input as a string
      counter++;//for counting rows number
      System.out.println(matrixView);// printing in output
    }

    scan.close();

    matrix = new int[counter] [matrixView.length()];//an array for keeping the value of each col and row


    scan = new Scanner(getFile);
    char getCol;
    for (int rows = 0; rows < counter; rows++){
      matrixView = scan.nextLine();
      for (int cols = 0; cols < matrixView.length(); cols++){
        getCol = matrixView.charAt(cols);//
        matrix[rows] [cols] = getCol;//
      }
    }



 
  }

}

SuggestionRe: Problem in scanning from file in Sudoku backtracking Pin
Richard MacCutchan13-Dec-12 23:50
mvpRichard MacCutchan13-Dec-12 23:50 
GeneralRe: Problem in scanning from file in Sudoku backtracking Pin
Member 858607214-Dec-12 0:17
memberMember 858607214-Dec-12 0:17 
GeneralRe: Problem in scanning from file in Sudoku backtracking Pin
Richard MacCutchan14-Dec-12 0:47
mvpRichard MacCutchan14-Dec-12 0:47 
GeneralRe: Problem in scanning from file in Sudoku backtracking Pin
Member 858607214-Dec-12 1:30
memberMember 858607214-Dec-12 1:30 
QuestionHow can I get the use of a female's voice in Java Pin
Showlar13-Dec-12 7:30
memberShowlar13-Dec-12 7:30 
AnswerRe: How can I get the use of a female's voice in Java Pin
Richard MacCutchan13-Dec-12 8:37
mvpRichard MacCutchan13-Dec-12 8:37 
AnswerRe: How can I get the use of a female's voice in Java Pin
TorstenH.16-Dec-12 20:50
memberTorstenH.16-Dec-12 20:50 
GeneralRe: How can I get the use of a female's voice in Java Pin
April Fans26-Dec-12 18:06
memberApril Fans26-Dec-12 18:06 
Questionj2me Pin
4yee12-Dec-12 8:23
member4yee12-Dec-12 8:23 
AnswerRe: j2me Pin
TorstenH.12-Dec-12 23:29
memberTorstenH.12-Dec-12 23:29 
SuggestionRe: j2me Pin
April Fans26-Dec-12 18:08
memberApril Fans26-Dec-12 18:08 
Questionparse and validation in validation.txt Pin
duka_pa11-Dec-12 12:05
memberduka_pa11-Dec-12 12:05 
AnswerRe: parse and validation in validation.txt Pin
Richard MacCutchan11-Dec-12 12:16
mvpRichard MacCutchan11-Dec-12 12:16 
Questionreading barcode Pin
junaid_ullah7-Dec-12 11:18
memberjunaid_ullah7-Dec-12 11:18 
AnswerRe: reading barcode Pin
Richard MacCutchan7-Dec-12 23:07
mvpRichard MacCutchan7-Dec-12 23:07 
GeneralRe: reading barcode Pin
junaid_ullah8-Dec-12 5:36
memberjunaid_ullah8-Dec-12 5:36 
GeneralRe: reading barcode Pin
Richard MacCutchan8-Dec-12 23:23
mvpRichard MacCutchan8-Dec-12 23:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 22 Feb 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid