Posted By:
23 Jun, 2013 1:08 pm PDT

Latin Square in C

What is a Latin Square and how can you print it in C?
Attachment:None


A Latin square depends on the number of elements the user wants. Suppose we consider for 5 elements then we�ll have the form 1 2 3 4 5 2 3 4 5 1 3 4 5 1 2 4 5 1 2 3 5 1 2 3 4 We use the following loop to print the square

int main()

{

    int i,j,k=1,n;   

    printf("\n Enter value of 'n' for Latin Square: ");

    scanf("%d",&n);

    for (i=1;i<=n;i++)

    {

        printf("\n");

        for (j=1;j<=n;j++)

        {

            printf(" %d",k);

            if (k==n)

                k=1;

            else

                k++;

        }

        k++;

    }

    getch();

}

Please see the video for more details.

Was it useful?  




Please login to reply to this problem.



Related Problems on Fixoncloud