import java.util.Scanner;
class Test2_For {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入三角形行数");
int a = sc.nextInt();
for (int i = 1;i <= a ;i++ ) {
for (int j = 1;j <= a - i ;j++ ) {
System.out.print(" ");
}
for (int k = 1;k <= i ;k++ ) {
System.out.print("* ");
}
System.out.println();
}
}
}
|
|