28 lines
706 B
C++
28 lines
706 B
C++
//Patriche Robert Cosmin
|
|
#include <iostream>
|
|
using namespace std;
|
|
|
|
void scambiaRigheColonne(int matrice[3][3], int righe, int colonne) {
|
|
int trasposta[3][3];
|
|
|
|
for (int i = 0; i < righe; i++) {
|
|
for (int j = 0; j < colonne; j++) {
|
|
trasposta[j][i] = matrice[i][j];
|
|
}
|
|
}
|
|
|
|
cout << "Matrice trasposta (righe scambiate con colonne): " << endl;
|
|
for (int i = 0; i < colonne; i++) {
|
|
for (int j = 0; j < righe; j++) {
|
|
cout << trasposta[i][j] << " ";
|
|
}
|
|
cout << endl;
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
int matrice[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
|
|
scambiaRigheColonne(matrice, 3, 3);
|
|
return 0;
|
|
}
|