1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package 上机练习;
 
import java.util.Scanner;
 
public class A04 {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner input = new Scanner (System.in);
        System.out.println("请输入三角形的行数:");
        int rows = input .nextInt();
        for (int i = 1; i <=rows; i++) {
            for (int j = 1; j <=rows+1-i; j++) {
                System.out.print("*");
            }
        System.out.println();
        }
    }
 
}