ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1313. Some Words about Sport

wa on #3
Posted by Shuhan 7 Mar 2013 23:41
first i hav taken input of 2d array.........and then sorted them using merge sort..... i know there is a problem in my logic.......but i can't find it......help me find it please.....


#include<stdio.h>

int main()
{
    int n,c,i,j,k,l,num;

    scanf("%d",&n);

    c=n-1;
    int ar[c][c];
    num=1;

    for(i=c;i>=0;i--)
    {
        for(j=0;j<n-i;j++)
        {
            ar[i][j]=num;
            num++;
        }
    }

        for(j=1;j<=c;j++)
        {
            for(i=0;i<n-i;i++)
            {
                ar[i][j]=num;
                num++;
            }
        }

            for(i=0;i<n;i++)
            {
                for(j=0;j<n;j++)
                {
                    printf("%d ",ar[i][j]);
                }
                printf("\n");
            }

            return 0;
}
Re: wa on #3
Posted by Anurag Pathak 15 Mar 2013 00:42
Hi, First of all, you don't need to sort the array. Read the Question properly, we just need to Reprint the Array in a Different Pattern of Diagnals, which is given in the Sample Output.