解题思路:
注意事项:
参考代码:
Scanner scanner=new Scanner(System.in);
int n=scanner.nextInt();
int a,b;
for (int i = 1; i <=n; i++) {
a=scanner.nextInt();
b=scanner.nextInt();
for (int j = 1; j <=b; j++) {
int num=a-1;
if (b==1||j==b) {
num=a;
}
for (int j1 = 1,x=0; j1 <= b; j1++,x++) {
for (int j2 = 1; j2 <=a; j2++) {
if (j2==j1||j2==a-x) {
System.out.print("X");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
System.out.println();
}
0.0分
3 人评分