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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#include<iostream>
#define MAX 20
using namespace ::std;
void citireM(int a[][MAX], int n, int m)
{
for(int i=0; i<n; i++)
for(int j=0; j<m; j++){
cout<<"a["<<i<<","<<j<<"]= ";
cin>>a[i][j];
}
}
void afisareM(int a[][MAX], int n, int m)
{
for(int i=0; i<n; i++){
cout<<endl;
for(int j=0; j<m; j++)
cout<<a[i][j]<<" ";
}
}
void calculT(int a[][MAX], int b[][MAX], int n, int m)
{
for(int i=0; i<n; i++)
for(int j=0; j<m; j++)
b[j][i] = a[i][j];
}
void roteste90(int a[][MAX], int b[][MAX], int n, int m)
{
for(int i=0; i<n; i++)
for(int j=0; j<m; j++)
b[i][j] = a[n-j-1][i];
}
int main()
{
int n,m,a[MAX][MAX],b[MAX][MAX];
cout << "Dati dimensiunile matricei " << endl;
cout << "Dati numarul de linii n = "; cin >> n;
cout << "Dati numarul de coloane m = "; cin >> m;
citireM(a,n,m);
cout << "Elementele matricei A sunt: " << endl;
afisareM(a,n,m);
//cout << "\nMatricea transpusa este: " << endl;
//calculT(a,b,n,m);
//afisareM(b,n,m);
cout << "\nMatricea rotita este: " << endl;
roteste90(a,b,n,m);
afisareM(b,n,m);
cin.ignore();
getchar();
return 0;
}
|