解题思路:
注意事项:
参考代码:
Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a,b; String arr[][]; for (int i = 0; i < n; i++) { a = sc.nextInt(); b = sc.nextInt(); arr = new String[a][a]; for (int j = 0; j < a; j++) { for (int k = 0; k < a; k++) { arr[j][k] = " "; } } for (int j = 0; j < b; j++) { for (int k = 0; k < a; k++) { arr[k][k] = "X"; arr[k][a - 1 - k] = "X"; } } for (int j = 0; j < b; j++) { if (j == 0) { for (int k = 0; k < a; k++) { for (int l = 0; l < a; l++) { System.out.print(arr[k][l]); } System.out.println(); } } else { for (int k = 1; k < a; k++) { for (int l = 0; l < a; l++) { System.out.print(arr[k][l]); } System.out.println(); } } } System.out.println(); }
0.0分
1 人评分
不会做的浏览:954 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:634 |
The 3n + 1 problem (C语言代码)浏览:603 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)from DQM浏览:773 |
用筛法求之N内的素数。 (C语言代码)浏览:711 |
母牛的故事 (C语言代码)浏览:594 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:592 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:561 |
1126题解浏览:649 |
1035 题解浏览:875 |