Browse Source

implemented a idea of how to make a simple sudoku

remotes/origin/develop
fdai6499 2 years ago
parent
commit
de3599c1f0
  1. 2
      ProjectDiary.md
  2. 46
      sudokuExample/src/Main.java

2
ProjectDiary.md

@ -1,2 +0,0 @@
Start
asjdbakjdsf

46
sudokuExample/src/Main.java

@ -0,0 +1,46 @@
import java.util.Scanner;
class Main {
//sudoku counts from 1 to 9 - sCount
static final int SCOUNT = 9;
static int field[][] = new int[SCOUNT][SCOUNT];
public static void main(String[] args) {
while (true) {
int[] transaction = readInput();
field[transaction[0]][transaction[1]] = transaction[2];
output(field);
}
}
private static void output(int[][] field) {
for (int i = 0; i < SCOUNT; i++) {
for (int j = 0; j < SCOUNT; j++) {
System.out.print(field[i][j] + " ");
}
System.out.println();
}
}
static int[] readInput() {
Scanner scanner = new Scanner(System.in);
String line = scanner.nextLine();
System.out.println(line);
String substring = line.substring(line.indexOf('(')+1, line.indexOf(')'));
String[] split = substring.split(",");
int[] transaction = new int[split.length];
for (int i = 0; i < split.length; i++) {
transaction[i] = Integer.valueOf(split[i]);
}
return transaction;
}
}
Loading…
Cancel
Save