*
***
*****
*******
每行有七个位置
package com.imooc;
public class helloword {
public static void main(String[] args) {
for(int i=0; i<=4;i++) {
for(int j=0;j<i;j++) {
System.out.print(" ");}
for(int k=i+1;k<4;k++) {
System.out.print("*");}
System.out.println();
}
}
}
把题目中的*换成空格,内层循环再加一个for循环k从j+1到length,输出*