int magicSquare(int* arr, int n) { int mid = n / 2; *(arr + mid) = 1; if (n <= 0) return 1; return magicSquare(arr,n-1); }
int main(){ int n; scanf("%d",&n); int arr[n][n]; int magicNumber = magicSquare(n); printf("Magic Number is %d\n",magicNumber); initialize(n,arr); printArr(n, arr); return 0; }
int main() { int n, *ptr=NULL,i=0; printf("홀 수 값을 입력 하세요: "); scanf("%d", &n); if (n < 0 || n % 2 == 0) { printf("입력값 에러!"); return 0; } ptr = malloc(sizeof(int)*(n*n)); for (; i < sizeof(ptr) / sizeof(int); i++) *(ptr + i) = 0; magicSquare(ptr, n); }
int main() { int a[100][100], i, j, n; printf("Enter the size of array(n*n): "); scanf("%d",&n); if(n%2 == 0) printf("n is even.\n"); else { magicSquare(n); printf("magic square is:\n"); for(i = 0; i<n; i++) { for(j = 0; j<n; j++) { printf("%-4d",square[i][j]); } printf("\n"); } } return 0; }