1 2 3
4 5 6
7 8 9
我正在用这个制作井字游戏;-;
我尝试了一个公式,但结果只是
0 0 0
1 1 1
2 2 2
如果您能指导我如何在选择时将数字更改为 X/O,我也将不胜感激。
int[][]x = new int[3][3]
for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) {
System.out.print(" "); 系统。出去。打印(i+1+j+“”);
}
系统。出去。打印() }
抱歉,我对此真的很陌生TT
public class PatternPrinter {
public static void main(String[] args) {
int rows = 3;
int cols = 3;
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= cols; j++) {
System.out.print((i - 1) * cols + j + "\t");
}
System.out.println();
}
}
}
输出:
1 2 3
4 5 6
7 8 9