Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help with magic squares

7 views
Skip to first unread message

JULIE SIGNER

unread,
Apr 19, 1997, 3:00:00 AM4/19/97
to dire...@emapnet.com

Hi. I would like to see some source code on generating a magic square
(of width 3 ) and find every combination for that width and sending it to
stdout.
Now I have to finish cleaning for Passover.

Thanks,
Julie


Sherry Goeller

unread,
Apr 21, 1997, 3:00:00 AM4/21/97
to

Ahhh...the dreaded MAGIC Square question...While I am certainly no pro at
programming I did one, while enrolled in a Pascal course last year. I won't
post the code, especially since it was Pascal, but I'll give you a hint.

Initialize the square with zero's
Set the corner square up with a value
Use a few IF's & FOR's with some logic in there.

See ya later alligator...

Sherry

she...@interlog.com
http://www.interlog.com/~sherryg

JULIE SIGNER <BO...@worldnet.att.net> wrote in article
<5jbh45$2...@mtinsc05.worldnet.att.net>...

Stephan Wilms

unread,
Apr 21, 1997, 3:00:00 AM4/21/97
to

JULIE SIGNER wrote:
>
> Hi. I would like to see some source code on generating a magic square
> (of width 3 ) and find every combination for that width and sending it to
> stdout.
> Now I have to finish cleaning for Passover.

DYOH

Stephan

E. Young

unread,
Apr 22, 1997, 3:00:00 AM4/22/97
to

On Mon, 21 Apr 1997, JULIE SIGNER wrote:
>MR EDWIN,
> GO GET A LIFE!!!! ANYBODY WHIO SPENDS THEIR TIME DISCUSSING THE C
> PROGRAMMING
> LANGUAGE NEEDS SERIOUS HELP!!! YOU WANT TO SEE EVIDENCE......KISS MY ASS!!!
> YOU DON'T WANT TO HELP BECAUSE YOU DON'T KNOW THE ANSWER.

Dear Julie (or is it Steve?),
How charming to discover that the ancient art of letter-writing is not
yet dead among today's American youth, even in this electronic age. But
it is even more heart-warming to discover that you place such a high value
on the virtues of hard work, diligent study and reasoned discourse. Your
ingenious strategy of insulting the very people who might possibly have
been willing to help you has paid off handsomely! For Lo! So taken am I
by the sparkling wit which shines through every phrase you write, that I
have added to this very message a "magic squares" program of my own
devising, just for you. I have also sent this message to the comp.lang.c
newsgroup, so they can join in the joyous celebrations. As those august
philosophers Ren and Stimpy might say, "Happy Happy Joy Joy!"

With my very warmest regards,

-Edwin

#include <stdio.h>
int C[42]={3,-4,-1,-2,1,4,2,-3},c_;
#define C(x,y) c_ = C [ x-c ] ; C[ x-c ] = C[ y-c ] ; C[ y-c ] = c_
#define c(a,b) if (* (a+C) + *(C + b + a ) + C[ a + b + b ] ) return
main(){_c(9);}_c(int c){int O=0;if(!c){c(3,1);c(6,1);c(0,3);c(2,3);c
(0,4);c(0,1);c(2,2);c(1,3);puts("");}for (;O<(c?c:9);O++)if(c){C(9+0
,9+O);_c(c-1);C(O+9,9+0);}else printf("%c%c",C[O]+'5'," \n"[O%3]);}

0 new messages