Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //W.P to change upper half of D[4][4] with the lower half of E[4][4] Use "function" statement.
- #include<iostream>
- using namespace std;
- void print_array(int a[][4],int x,int y)
- {
- for(int i=0;i<x;i++)
- {
- for(int j=0;j<y;j++)
- {
- cout<<a[i][j]<<"\t";
- }
- cout<<endl<<endl;
- }
- cout<<"------------------------------------\n";
- }
- void change(int a[][4],int x,int y,int b[][4],int r,int c)
- { int k[4][4],i,j;
- for(i=0;i<x-2;i++)
- {
- for(j=0;j<y;j++)
- {
- k[i][j]=a[i][j];
- a[i][j]=b[i+2][j];
- b[i+2][j]=k[i][j];
- }
- }
- }
- int main()
- {
- int c[4][4],e[4][4],i,j;
- cout<<"Input for c[][] array\n";
- for(i=0;i<4;i++)
- {
- for(j=0;j<4;j++)
- {
- cout<<"["<<i<<"]["<<j<<"]";
- cin>>c[i][j];
- }
- }
- cout<<"\nInput for E[][] array\n";
- for(i=0;i<4;i++)
- {
- for(j=0;j<4;j++)
- {
- cout<<"["<<i<<"]["<<j<<"]";
- cin>>e[i][j];
- }
- }
- print_array(c,4,4);
- print_array(e,4,4);
- change(c,4,4,e,4,4);
- print_array(c,4,4);
- print_array(e,4,4);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement