Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void print_array(int a[][3],int x,int y,int c[],int r)
- {
- int i,j;
- cout<<"\narray a[][]\n";
- for(i=0;i<x;i++)
- {
- for(j=0;j<y;j++)
- {
- cout<<a[i][j]<<"\t";
- }
- cout<<endl<<endl;
- }
- cout<<"array c[]\n";
- for(i=0;i<r;i++)
- {
- cout<<c[i]<<"\t";
- }
- }
- void swap_array(int a[][3],int x,int y,int c[],int r)
- {
- int j,temp;
- for(j=0;j<y;j++)
- {
- temp=a[0][j];
- a[0][j]=c[j];
- c[j]=temp;
- }
- }
- int main()
- {
- int a[3][3],i,j,c[3];
- cout<<"array a[][]\n";
- for(i=0;i<3;i++)
- {
- for(j=0;j<3;j++)
- {
- cout<<"["<<i<<"]["<<j<<"]";
- cin>>a[i][j];
- }
- }
- cout<<"array C[]\n";
- for(i=0;i<3;i++)
- {
- cout<<"["<<i<<"]";
- cin>>c[i];
- }
- print_array(a,3,3,c,3);
- swap_array(a,3,3,c,3);
- print_array(a,3,3,c,3);
- }
Advertisement
Add Comment
Please, Sign In to add comment