-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrizTranspuesta.cpp
More file actions
49 lines (35 loc) · 995 Bytes
/
matrizTranspuesta.cpp
File metadata and controls
49 lines (35 loc) · 995 Bytes
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
//Matriz transpuesta: cambiar las filas a columnas y viceverza
#include <iostream>
using namespace std;
int main(){
int a[3][3], b[3][3], n = 3;
for (int i = 0; i < n ; i++) {
for(int j = 0; j < n; j++){
cout << "Ingresa los valores de la matriz [" << i+1 << "][" << j+1 << "]: ";
cin >> a[i][j];
}
}
for (int i = 0; i < n ; i++) {
for(int j = 0; j < n; j++){
b[i][j] = a[j][i];
}
}
cout << endl;
//Imprime la matriz final a
for (int i = 0; i < n ; i++) {
for(int j = 0; j < n; j++){
cout << a[i][j] << " ";
}
cout << endl;
}
cout << "**********************************************************" << endl;
//Imprime la matriz final transpuesta b
for (int i = 0; i < n ; i++) {
for(int j = 0; j < n; j++){
cout << b[i][j] << " ";
}
cout << endl;
}
system("pause");
return 0;
}