题解 | #圣诞树#
圣诞树
http://www.nowcoder.com/practice/9a03096ed8ab449e9b10b0466de29eb2
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int e = 3*n-1; for(int i=0;i<n;i++){ for(int k=0;k<e;k++){ System.out.print(" "); } for(int j=0;j<i+1;j++){ System.out.print("*"); System.out.print(" "); } System.out.println(); e -=1; for(int k=0;k<e;k++){ System.out.print(" "); } for(int j=0;j<i+1;j++){ System.out.print("* *"); System.out.print(" "); } System.out.println(); e -=1; for(int k=0;k<e;k++){ System.out.print(" "); } for(int j=0;j<i+1;j++){ System.out.print("* * *"); System.out.print(" "); } System.out.println(); e -=1; } for(int i=1;i<=n;i++) { for(int j=1;j<=3*n-1;j++) { System.out.print(" "); } System.out.println("*"); } } }