使用for循环打印等腰三角形

public class Test {
public static void main(String[] args) {
//控制行
for (int i = 0; i < 7; i++) {
//控制列
for (int j = 6; j >i; j--) {
//按列输出
System.out.print(" ");
}
for (int j = 0; j <=i; j++) {
//按列输出
System.out.print("*");
}
for (int j = 0; j < i; j++) {
System.out.print("*");
}
System.out.println();
}

}

}

猜你喜欢

转载自blog.csdn.net/xzm616663858/article/details/69662807
今日推荐