-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprueba vector de vectores.cpp
More file actions
57 lines (49 loc) · 1.41 KB
/
prueba vector de vectores.cpp
File metadata and controls
57 lines (49 loc) · 1.41 KB
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
#include <iostream>
#include <vector>
int main()
{
int fil, col;
int val = 0; //<-- ESTE VALOR AUMENTARA
std::vector<int> papu;
std::vector< std::vector<int> > matriz;
std::cout << "FILAS: ";
std::cin >> fil;
std::cout << "COLUMNAS: ";
std::cin >> col;
for (int i = 0;i < fil;i++){
//Almacena los elementos de la columna
std::vector<int> v1;
for (int j = 0; j < col; j++) {
std::cout << "Valor [" << i << "][" << j << "] = ";
std::cin >> val;
v1.push_back(val);
}
//Agregamos los elementos de las columas (por fila)
matriz.push_back(v1);
}
//Mostrar matriz
for (int i = 0; i < matriz.size(); i++) {
for (int j = 0; j < matriz[i].size();j++) {
std::cout << matriz[i][j] << " ";
}
std::cout << std::endl;
}
system("pause");
std::cout << "\nALTERANDO LOS ELEMENTOS!!!" << std::endl;
int nuevos;
for (int i = 0; i < fil; i++) {
for (int j = 0; j < col; j++) {
std::cout << "Valor [" << i << "][" << j << "] = ";
std::cin >> nuevos;
matriz[i][j] = nuevos;
}
}
//Mostrar matriz
for (int i = 0; i < matriz.size(); i++) {
for (int j = 0; j < matriz[i].size(); j++) {
std::cout << matriz[i][j] << " ";
}
std::cout << std::endl;
}
system("pause");
}