Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void out_array(int a[],int n)
- {
- for(int i=0;i<n;i++)
- cout<<a[i]<<" ";
- }
- void Distribute(int a[],int n,int b[],int &nb,int c[],int &nc,int k)
- {
- int i,pa,pb,pc;
- pa=pb=pc=0;
- while(pa<n);
- {
- cout<<pa<<" and "<<n<<endl;
- for(i=0;(pa<n)&&(i<k);i++,pa++,pb++)
- b[pb]=a[pa];
- for(i=0;(pa<n)&&(i<k);i++,pa++,pc++)
- c[pc]=a[pa];
- }
- nb=pb; nc=pc;
- }
- int main()
- {
- int n=8,a[8]={12,2,8,5,1,6,4,15};
- int b[n],c[n],nb,nc;
- Distribute(a,n,b,nb,c,nc,1);
- out_array(b,nb);
- cout<<endl<<"===="<<endl;
- out_array(c,nc);
- cout<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment