#include<stdio.h> #include<conio.h> int main() { int col,row,i,size,totalSize; printf("please enter size of magic box\n"); scanf("%d",&size); totalSize =size * size; printf("total magic square size %d\n",totalSize); for(i=1;i<=totalSize;i++) { if(i==1) { row =1; col=(size+1)/2; }else if(((i-1) % size) == 0){ row++; }else{ row--; col--; if(row == 0) row = size; if(col == 0) col = size; } gotoxy(col,row); printf("%d",i); } return 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)