|
|
back to boardwtf?! WHY WA #2 Posted by sim40 8 Apr 2008 23:45 please help me here is my program: #include<iostream> using namespace std; int n,k,a[128],b[128],i,j,p,m,k1,k2,n1; int main() { cin>>n>>k; for(i=1;i<=n;i++) cin>>a[i]; if(n%k==0)k2=k1=n/k; else { if(k==2){k1=k2=n/2;k1++;} else { n1=n; while(n1) { n1--; if(n1%(k-1)==0){k1=n1/(k-1);k2=(n-n1);break;} } } } for(i=1;i<k;i++) b[i]=k1; b[k]=k2; for(i=1;i<=b[1];i++) { p=i; for(j=1;j<=k-1;j++) { if(a[p]<10)cout<<" "<<a[p]; else if(a[p]<100)cout<<" "<<a[p]; else if(a[p]<1000)cout<<" "<<a[p]; p+=b[j]; } if(p<=n) { if(a[p]<10)cout<<" "<<a[p]; else if(a[p]<100)cout<<" "<<a[p]; else if(a[p]<1000)cout<<" "<<a[p]; } if(i!=b[1])cout<<endl; } } |
|
|