1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include<iostream.h>
void swapcol(int [50][50],int,int);
int main()
{int a[50][50],r,c,m,n;
cout<<"enter no of row \n";
cin>>m;
cout<<"enter no of column \n";
cin>>n;
cout<<"enter element \n";
for(r=0;r<m;r++)
{ for(c=0;c<n;c++)
{cin>>a[r][c];
}
}
swapcol(a,m,n);
cout<<"after swaping \n";
for(r=0;r<m;r++)
{ for(c=0;c<n;c++)
{cout<<a[r][c];
cout<<"done"<<endl;
}
}
return 0;
}
void swapcol(int a[50][50],int m,int n)
{int r,c,c1,b;
for(r=0;r<m;r++)
{ for(;c=0,c1=n-1;)
{ b=a[r][c];
a[r][c1]=a[r][c];
a[r][c1]=b;
}
}
}
|