|
|
вернуться в форумMy AC solution Послано Homka 30 янв 2012 17:09 C++, 0.015 sec, 196 Kb #include <iostream> using namespace std; int main() { int n,k; cin>>n>>k; int m=n/k + ((n%k==0) ? 0:1); int * A=new int [m*k]; for (int i=0;i<n;i++) { cin>>A[i]; } for (int i=n;i<m*k;i++) A[i]=-1; for (int i=0;i<m;i++) { for (int j=0;j<k;j++) { int h=j*m+i; if (A[h]<0) cout<<" "; if (A[h]>-1 && A[h]<10) cout<<" "<<A[h]; if (A[h]>9 && A[h]<100) cout<<" "<<A[h]; if (A[h]>99 && A[h]<1000) cout<<" "<<A[h]; } cout<<endl; } return 0; } Waiting of comments My AC solution Послано Sunnat 4 дек 2012 17:50 C, 0.015 sec, 112 kb main() { short n,k,a[101],i,j; scanf("%d %d",&n,&k); k=(n+k-1)/k; for(i=0;i<n;i++)scanf("%i",&a[i]); for(j=0;j<k;puts(""),j++) for(i=j;i<n;i+=k) printf("%4d",a[i]); } |
|
|