三角形(*.打印)

 1 package com.trfizeng.graphis;
 2 /**
 3  * @author trfizeng
 4  * 
 5   三角形打印
 6   *  
 7 
 8   *.*.  
 9 
10   *..*..*..  
11 
12   *...*...*...*...  
13 
14   *....*....*....*....*....  
15 
16   *.....*.....*.....*.....*.....*.....  
17 
18   *......*......*......*......*......*......*......  
19 
20   *.......*.......*.......*.......*.......*.......*.......*.......
21  
22  *
23  */
24 public class PrintSanJiaoXing {
25     public static void main(String[] args) {
26         for (int i = 1; i <= 8; i++) {
27             if (i == 1) {
28                 System.out.print("*");
29             } else {
30                 int j = 0;
31                 while (j < i) {
32                     int k = 0;
33                     System.out.print("*");
34                     while (k < i - 1) {
35                         System.out.print(".");
36                         k++;
37                     }
38                     j++;
39                 }
40             }
41             System.out.println("\n");
42         }
43     }
44 }
View Code

print:

*

*.*.

*..*..*..

*...*...*...*...

*....*....*....*....*....

*.....*.....*.....*.....*.....*.....

*......*......*......*......*......*......*......

*.......*.......*.......*.......*.......*.......*.......*.......

 

posted on 2015-03-24 21:25  trfizeng  阅读(285)  评论(0编辑  收藏  举报

导航