参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int n=scanner.nextInt(); for (int i = 0; i < n; i++) { int a=scanner.nextInt(); int b=scanner.nextInt(); char[][] num=new char[a][a]; for (int j = 0; j < num.length; j++) { for (int j2 = 0; j2 < num[j].length; j2++) { num[j][j2]=' '; } } for (int j = 0; j < num.length; j++) { num[j][0+j]='X'; num[j][num[j].length-1-j]='X'; } for(int t=0;t<b;t++){ if (t>0) { for (int j = 1; j < num.length; j++) { for (int j2 = 0; j2 < num[j].length; j2++) { System.out.print(num[j][j2]); } System.out.println(); } }else { for (int j = 0; j < num.length; j++) { for (int j2 = 0; j2 < num[j].length; j2++) { System.out.print(num[j][j2]); } System.out.println(); } } } System.out.println(); } } }
0.0分
1 人评分
众数问题 (C语言代码)浏览:3515 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:586 |
妹子杀手的故事 (C语言代码)浏览:691 |
C语言训练-大、小写问题 (C语言代码)浏览:2357 |
C语言训练-排序问题<1> (C++代码)浏览:604 |
A+B for Input-Output Practice (IV) (C语言代码)浏览:457 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:575 |
wu-理财计划 (C++代码)浏览:837 |
2004年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:1341 |
简单的a+b (C语言代码)浏览:578 |