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

Join 119,059 C# Programmers for FREE! Ask your question and get quick answers from experts. There are 1,445 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

 
Closed TopicStart new topic

Help, Plz Help me

kmaro
post 8 Aug, 2008 - 09:09 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


zakary
post 8 Aug, 2008 - 09:34 AM
Post #2


D.I.C Regular

Group Icon
Joined: 15 Feb, 2005
Posts: 385



Thanked 4 times

Dream Kudos: 175
My Contributions


what are you trying to do? what is the problem you are having?
User is offlineProfile CardPM

Go to the top of the page

kmaro
post 8 Aug, 2008 - 09:43 AM
Post #3


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

jayman9
post 8 Aug, 2008 - 03:32 PM
Post #4


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,478



Thanked 28 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


Please do not create duplicate topics.

Topic closed.
User is online!Profile CardPM

Go to the top of the page

Closed TopicStart new topic
Time is now: 10/13/08 04:02PM

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