Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
algorithm:algorithm [2016/06/07 13:19] ledyxalgorithm:algorithm [2022/10/24 15:32] (current) ledyx
Line 2: Line 2:
  
 {{tag>Algorithm}} {{tag>Algorithm}}
- 
-= 마방진 (Magic Square) = 
-  * 홀수만 처리 가능! 
-<sxh java ; title:Language : Java> 
-int size = 5; 
- 
-int[][] arr = new int[size][size]; 
-  
-int middle = size/2; 
- 
-int i=0, j=middle; 
-for(int num=1 ; num<=size*size ; num++) { 
- arr[i][j] = num; 
-  
- //행 감소 
- i--; 
- if(i < 0) 
- i = size-1; 
-  
- //열 증가 
- j = (++j)%size; 
- //아래 표현과 같다. 
- /*j++; 
- if(j >= size) 
- j = 0;*/ 
- 
- //배수이면 행은 1 증가, 열은 그대로 
- if(num%size == 0) { 
- i = (i+2)%size; 
- j--; 
- if(j < 0) 
- j = size-1; 
- } 
-} 
-</sxh> 
  
 = Recursion = = Recursion =
Line 53: Line 18:
 == Binary Search (이진 탐색) == == Binary Search (이진 탐색) ==
 [[binary search|참조]] [[binary search|참조]]
 +
algorithm/algorithm.1465305576.txt.gz · Last modified: (external edit)