29-01-2013, 05:15 PM | #1 |
VIP Member
|
C Program for Ramanujam's Magic square
#include<conio.h> void main() { int a[20][20],r,c,br,bc,k,n; clrscr(); printf("Enter the Order of Magic Square(Odd): "); scanf("%d",&n); for(r=0;r<n;r++) for(c=0;c<n;c++) a[r][c]=0; r=0; c=n/2; for(k=1;k<=n*n;k++) { a[r][c]=k; br=r++;bc=c++; r=(r+1)%n; c=(c+1)%n; if(a[r][c]!=0) { c=bc; r=br-1; if(r<0)r=n-1; } } printf("The Magic Square...\n"); for(r=0;r<n;r++) { for(c=0;c<n;c++) printf("%4d",a[r][c]); printf("\n"); } }
__________________
Disclamer :- All the My Post are Free Available On INTERNET Posted By Somebody Else, I'm Not VIOLATING Any COPYRIGHTED LAW. If Anything Is Against LAW, Please Notify So That It Can Be Removed. |
30-01-2013, 08:37 AM | #2 |
Special Member
Join Date: Dec 2012
Location: फूटपाथ
Posts: 3,861
Rep Power: 23 |
Re: C Program for Ramanujam's Magic square
nice pg.. thanks for sharing..
__________________
With the new day comes new strength and new thoughts.
|
30-01-2013, 06:08 PM | #3 |
VIP Member
|
Re: C Program for Ramanujam's Magic square
__________________
Disclamer :- All the My Post are Free Available On INTERNET Posted By Somebody Else, I'm Not VIOLATING Any COPYRIGHTED LAW. If Anything Is Against LAW, Please Notify So That It Can Be Removed. |
Bookmarks |
|
|