Created
          January 1, 2020 07:42 
        
      - 
      
- 
        Save dalcon10028/4b69cf3c2a085724d53553f2d6f805e8 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import java.util.*; | |
| public class Main { | |
| static char field[][]; | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| int N = sc.nextInt(); | |
| sc.close(); | |
| field = new char[N][N]; | |
| StringBuilder sb = new StringBuilder(); | |
| for(int i=0;i<N;i++) Arrays.fill(field[i],' '); | |
| star(N, 0, 0); | |
| for(int i= 0; i<N; i++){ | |
| for(int j=0; j<N; j++) | |
| sb.append(field[i][j]); | |
| sb.append("\n"); | |
| } | |
| System.out.println(sb); | |
| } | |
| public static void star(int n, int x, int y) { | |
| if (n==1) { // 마지막 처리 | |
| field[y][x] = '*'; | |
| return; | |
| } | |
| star(n/3, x, y); // 좌상 | |
| star(n/3, x+n/3, y); // 상 | |
| star(n/3, x+n/3*2, y); // 우상 | |
| star(n/3, x, y+n/3); // 좌 | |
| star(n/3, x+n/3*2, y+n/3); // 우 | |
| star(n/3, x, y+n/3*2); // 좌하 | |
| star(n/3, x+n/3, y+n/3*2); // 하 | |
| star(n/3, x+n/3*2, y+n/3*2); // 우하 | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment