/**
* 作者:
* 日期:2013-11-09
* 功能:打印出金字塔形状
*/
package com.cn;
public class Testfor {
public static void main(String args[]){
int i = 7;//表示共有多少行
int n; //代表当前行
for(n = 1;n<=i;n++){
for(int a=1;a<=(i-n);a++){
System.out.print(" ");
}
for(int b=1;b<=(2*n-1);b++){
System.out.print("*");
}
System.out.println();
}
}
}
打印出金字塔形状
最新推荐文章于 2022-09-18 20:00:10 发布