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

what is wrong with my code
Posted by esger 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;
}
Re: what is wrong with my code
Posted by ░▒ Nguyễn Kim Vỹ ▒░ 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
Re: what is wrong with my code
Posted by Mehran.R 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.