Java循环练习:打印图案-5

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package practiceGO;
/*
 * *
 * **
 * * *
 * *  *
 * *****
 */
public class Cto {
 
    public static void main(String[] args) {
        for(int i=0; i<5; i++){
            for(int j=0; j<(i+1); j++){
                if (i>=2 && i<=3) {
                    if (j==0 || j==i) {
                        System.out.print("*");
                    }else {
                        System.out.print(" ");
                    }
                }else{
                    System.out.print("*");
                }
            }
            System.out.println();
        }
    }
}

运行结果:

1
2
3
4
5
*
**
* *
*  *
*****


上一篇:彻底解决Oracle中文乱码


下一篇:天啦撸!打印日志竟然只晓得 Log4j?(1)