我无法正确输出代码。除了空间部分(首先嵌套for循环)之外,我已经把它弄好了。
public class Practice {
public static void main(String[] args) {
Top();
}
public static void Top() {
for (int a = 1; a <= 5; a++) {
for (int b = 1; b <= 5; b++) {
System.out.print(" ");
}
for (int c = 1; c <= a; c++) {
System.out.print("/");
}
System.out.print("**");
for (int d = 1; d <= a; d++) {
System.out.print("\\");
}
System.out.println();
}
}
}
期望的输出:
/**\
//**\\
///**\\\
////**\\\\
/////**\\\\\
答案 0 :(得分:0)
更改行:
for (int b = 1; b <= 5; b++) {
为:
for (int b = 1; b <= 5 - a; b++) {