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 }
print:
*
*.*.
*..*..*..
*...*...*...*...
*....*....*....*....*....
*.....*.....*.....*.....*.....*.....
*......*......*......*......*......*......*......
*.......*.......*.......*.......*.......*.......*.......*.......
原文:http://www.cnblogs.com/trfizeng/p/4364040.html