- import java.util.*;
- class print3 {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- System.out.print("请输入你想打印的三角形行数:");
- int a = in.nextInt();
- print(a);
- }
- public static void print(int a) {
- for(int i = 0; i < a; i++) {
- for(int j = 0; j <= i; j++) {
- System.out.print("*");
- }
- System.out.println("");
- }
- }
- }
复制代码 |