-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsumar_matrices.cpp
63 lines (56 loc) · 1.17 KB
/
sumar_matrices.cpp
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
#include <iostream>
using namespace std;
main(){
int n;
cout << "Ingrese el valor de n: \n";
cin >> n;
int matriz1[n][n], matriz2[n][n], matrizResultante[n][n];
cout << "Ingrese los datos de la primera matriz:\n";
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
matriz1[i][j] = i;
//cin >> matriz1[i][j];
}
}
cout << "la primera matriz es:\n";
for (int i = 0; i < n; i++){
cout << "[";
for (int j = 0; j < n; j++){
cout << matriz1[i][j];
if (j != n-1){
cout << ", ";
}
}
cout << "]\n";
}
cout << "\nIngrese los datos de la segunda matriz:\n";
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
matriz2[i][j] = i+1;
//cin >> matriz2[i][j];
}
}
cout << "la segunda matriz es:\n";
for (int i = 0; i < n; i++){
cout << "[";
for (int j = 0; j < n; j++){
cout << matriz2[i][j];
if (j != n-1){
cout << ", ";
}
}
cout << "]\n";
}
cout << "\nla matriz suma es:\n";
for (int i = 0; i < n; i++){
cout << "[";
for (int j = 0; j < n; j++){
matrizResultante[i][j] = (matriz1[i][j]+matriz2[i][j]);
cout << matrizResultante[i][j];
if (j != n){
cout << ", ";
}
}
cout << "]\n";
}
}