import java util Scanner Created by Константин on 13 09 2014 public cl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.util.Scanner;
/**
* Created by Константин on 13.09.2014.
*/
public class Primer {
public static void main() {
static void exercises7 () {
char[] charArray = new char[9];
for (int i = 0; i < charArray.length; i++) {
charArray[i] = '_';
}
for (int i = 0; i < charArray.length; i++) {
if (i % 3 != 2) {
System.out.print(charArray[i] + "");
} else {
System.out.println(charArray[i] + "\n");
}
}
Scanner scanner = null;
while (true) {
System.out.println("Введите координаты ячейки. Для выхода введите 0");
scanner = new scanner(System.in);
int numbRow = scanner.nextInt();
if (numbRow == 0) {
System.out.println("GAME OVER");
scanner.close();
return;
}
int numbCol = scanner.nextInt();
scanner = null;
scanner = new Scanner(System.in);
System.out.println("Введите символ");
char symbol = scanner.nextLine().charAt();
int index = numbCol + (numbRow - 1) * 3 - 1;
System.out.println(
"NumberRow = " + numbRow + ",NumberColumn =" +
numbCol + ",i =" + index);
charArray[index] = symbol;
for (int i = 0; i < charArray.length; i++) {
if (i % 3 != 2) {
System.out.print(charArray[i] + " ");
} else {
System.out.print(charArray[i] + "\n");
}
}
}
}
}