Hallo,
Wie kann ich ein Sudoku am einfachsten über die Kommandozeile einlesen?
Wie kann ich ein Sudoku am einfachsten über die Kommandozeile einlesen?
Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
java -jar sodoku.java 0,1,2,#,5,#,#,8,9,4;#,4,0,2,1,...
int Matrix[][]=new int[8][8];
Scanner sc = new Scanner(System.in);
int eingabe =sc.nextInt();
for(int m=0; m<Matrix.length; m++) {
for(int n=0; n<Matrix.length; n++) {
Matrix[m][n]=eingabe;
}
}
int Matrix[][] = new int[9][9];
Scanner sc = new Scanner(System.in); // Scanner zur Eingabe
for (int m = 0; m < 9; m++) {
String eingabe = sc.nextLine();
for (int n = 0; n < 9; n++) {
Matrix[m][n] = eingabe.charAt(n) - '0';
}
}