我已经能够将两个图像一个打印在另一个上面,但我还需要将它们打印在一起。有人可以帮帮我吗? (我需要能够在我已经得到的东西下打印出来)
广场和三角形代码在另一个
之上 for (int i = 0; i < 4; i++) {
for (int j = 0; j < 5; j++) {
System.out.print(" *");
}
System.out.println("");
}
System.out.println("");
for (int i = 1; i <= 4; i++) {
for (int j = 1; j <= 5-i; j++) {
System.out.print(" ");
}
for (int k = 1; k <= i; k++) {
System.out.print(" *");
}
System.out.print("\n");
}
答案 0 :(得分:0)
只需将两个最外层的for循环组合起来:
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 5; j++) {
System.out.print(" *");
}
for (int j = 1; j <= 5 - i+1; j++) {
System.out.print(" ");
}
for (int k = 1; k <= i+1; k++) {
System.out.print(" *");
}
System.out.print("\n");
}
System.out.println("");