---
# System prepended metadata

title: ChristmasTreeLab1
tags: [JAVA]

---

#    ChristmasTreeLab1
###### tags: `JAVA`
```
public class ChristmasTreeLab1 {
    public static void main(String[] args) {

        int n = 5;
        int max = 2*n - 1;

        for (int i=0; i < n ;i++){
            //輸出空格
            for (int j= 0 ; j < (max-(i*2+1))/2 ; j++){
for (int j= 0 ; j < (max-(i*2+1))/2 ; j++){
                System.out.print(" ");
            }                System.out.print(" ");
            }
            //輸出*
            for (int k= 0 ; k < 2*i+1 ; k++){
                System.out.print("*");
            }
            //輸出換一行
            System.out.println();
        }
    }
}
```
