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 1506. Columns of Numbers

WA#1
Posted by Samvel 3 Jun 2008 20:36
My answer is right on computer's test, but I don't understand, why I've got WA#1.
Please, help me.
Here my code

# include<iostream.h>
int main()
{
    int n, k, a[101], i, j=0, h=0, p, b[101][101];
    cin>>n>>k;
    if (n%k==0)
        p=n/k;
    else
        p=n/k+1;
    for (i=0; i<n; i++)
    {
        cin>>a[i];
        if (j==p)
        {
            j=0;
            b[j++][++h]=a[i];
        }
        else
            b[j++][h]=a[i];
    }
    for (i=0; i<p; i++)
    {
        for (j=0; j<k && b[i][j]>=0 && b[i][j]<1000;j++)
        {
            if (b[i][j]>=0 && b[i][j]<=9)
                cout<<"   "<<b[i][j];
            else if (b[i][j]>=10 && b[i][j]<=99)
                cout<<"  "<<b[i][j];
            else
                cout<<" "<<b[i][j];
        }
        if (i<p-1)
            cout<<endl;
    }
    return 0;
}

Edited by author 03.06.2008 20:40