打印*

package Num1;
public class Main {
public void Test(int n){
System.out.println("你输入的三角形如图");
for(int i = 0;i < n;i++){
for(int j = 0;j < n-1-i;j++){
System.out.print("");
}
for(int k = 0;k<=i;k++){
System.out.print("*");
}
//每遍历一次换行
System.out.println("");
}
}


public static void main(String[] args) {
Main n = new Main(); //类名 方法名 = new 类名();
n.Test(7); //方法名.函数名


}

}

原文地址:https://www.cnblogs.com/hzp0619/p/8672256.html