#include<fstream>
using namespace std;
ifstream fin("f.in");
ofstream fout("f.out");
void citire(int a[20][20], int &n, int &m)
{
int i,j;
fin>>n>>m;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
fin>>a[i][j];
}
void afisare(int a[20][20], int n, int m)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
fout<<a[i][j]<<" ";
fout<<endl;
}
}
void copiaza(int a[20][20], int b[20][20], int n, int m)
{
int i,j;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
b[i][j]=a[i][j];
}
void invers_lin_med(int a[20][20], int n, int m)
{
int i,j,aux;
for(i=1;i<=n/2;i++)
for(j=1;j<=m;j++)
{
aux=a[i][j];
a[i][j]=a[n+1-i][j];
a[n+1-i][j]=aux;
}
}
void invers_col_med(int a[20][20], int n, int m)
{
int i,j,aux;
for(j=1;j<=m/2;j++)
for(i=1;i<=n;i++)
{
aux=a[i][j];
a[i][j]=a[i][m+1-j];
a[i][m+1-j]=aux;
}
}
void transpusa(int a[20][20], int b[20][20], int n, int m)
{
int i,j,aux;
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
b[j][i]=a[i][j];
}
int main()
{
int a[20][20],b[20][20],n,m;
citire(a,n,m);
copiaza(a,b,n,m);
invers_lin_med(b,n,m);
fout<<"Inversare fata de linia mediana:\n";
afisare(b,n,m);
copiaza(a,b,n,m);
invers_col_med(b,n,m);
fout<<"Inversare fata de coloana mediana:\n";
afisare(b,n,m);
copiaza(a,b,n,m);
invers_col_med(b,n,m);
invers_lin_med(b,n,m);
fout<<"Inversare fata de centrul matricii:\n";
afisare(b,n,m);
transpusa(a,b,n,m);
fout<<"Transpusa:\n";
afisare(b,m,n);
return 0;
}
|