Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 109,554 C# Programmers for FREE! Ask your question and get quick answers from experts. There are 1,322 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Help

 
Reply to this topicStart new topic

Help, I'm trying to do odd magic square and i need to the way plz??

kmaro
post 8 Aug, 2008 - 09:46 AM
Post #1


New D.I.C Head

*
Joined: 8 Aug, 2008
Posts: 3

CODE


void CalculateOddMagicSquare()
{
  n=5;
  int matrix[5][5];

  int nsqr = n * n;
  int i=0, j=n/2;     // start position

  for (int k=1; k<=nsqr; ++k)
  {
    matrix[i][j] = k;

    i--;
    j++;

    if (k%n == 0)
    {
      i += 2;
      --j;
    }
    else
    {
      if (j==n)
        j -= n;
      else if (i<0)
        i += n;
    }
  }
}
User is offlineProfile CardPM

Go to the top of the page


jjsaw5
post 8 Aug, 2008 - 12:07 PM
Post #2


D.I.C. Face

Group Icon
Joined: 4 Jan, 2008
Posts: 984



Thanked 5 times

Dream Kudos: 125
My Contributions


Just a couple things, please use a better thread title then just "Help"

and second what problems are you having? I see you posted some source code but you don't explain anything at all.

Could you please provide more information.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/7/08 10:59PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month