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

esger what is wrong with my code [2] // Problem 1506. Columns of Numbers 8 Jun 2010 18:51
I get WA#1
here is my code

#include <cstdlib>
#include <iostream>

using namespace std;
int i, j, n, k, say, a[101];

int main(int argc, char *argv[])
{
            cin >> n >> k;

                for( i = 0; i < n ; i++ )
                    cin >> a[ i ];
                   if( n%k != 0)
                    say = n/k + 1;
        else
            say = n/k;

                for( j = 0; j < say; j++ ){
                        cout << a[ j ];
                        i = j + say;
                        while( i < n){

                            cout <<" "<< a[ i ];
                            i += say;
                        }
                        if( j < say-1 )
                        cout << endl;
                        }



    return 0;
}
░▒ Nguyễn Kim Vỹ ▒░ Re: what is wrong with my code // Problem 1506. Columns of Numbers 23 Jul 2010 00:19
Output: The width of each column must be 4 symbols; the numbers must be aligned to the right edge and padded with spaces to the required width
Mehran.R Re: what is wrong with my code // Problem 1506. Columns of Numbers 27 Oct 2010 16:34
hi.you have 3 error's
1.you get 1 test case,but question has t test case.
you can add while(cin>>n>>k){...} to het t,test case,t>0;
2.you end of ant test case add cout<<endl;
3.to any answer printf(" %3d",a[i]);
good luck.