|
|
back to boardwhat 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 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 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. |
|
|