Matrices
Conceptos bsicos
Los arrays ms usuales son los de
dos
dimensiones,
conocidos
tambin por el nombre de tablas
o matrices.
Sin embargo, es posible crear
arrays de tantas dimensiones
como requieran sus aplicaciones,
esto es, tres, cuatro o ms
dimensiones.
Un
array de dos dimensiones
equivale a una tabla con mltiples
filas y mltiples columnas tal
como se precia en la siguiente
figura.
Ing. Zegarra Henry
Matrices
Declaracin de Matrices
Una
matriz tiene filas y
columnas,
entonces,
se
debe de indicar el nmero
de filas y columnas que
poseer la matriz.
El formato general para la
declaracin de una variable
de
tipo
vector
es
el
siguiente:
Tipo_de_datos mat1 [tFil] [tCol], , matN [tFil] [tCol];
Ing. Zegarra Henry
Matrices
Declaracin de Matrices
De
la sintaxis anterior
decir:
Tipo_de_Datos
mat1, , matN
[tFil]
podemos
int.
float.
double.
Nombre de la matriz.
Tamao de fila.
[tCol] Tamao de columna.
Ing. Zegarra Henry
Matrices
Declaracin de Matrices
Algunos ejemplos:
// Se declaran dos matrices mat1 y
mat2
// de tipo entero y
flotante de
dimensiones 3x3.
int mat1[3][3];
float mat2[3][3];
Ing. Zegarra Henry
Matrices
mat1[0][0]
Columna
j=2
Columna
j=0
Columna
j=1
Declaracin de Matrices
Analizando las matrices anteriores
Fila
i=0
Fila
i=1
Fila
i=2
mat1
Ing. Zegarra Henry
mat1[1][2]
Ingrese nmero de filas (Max. 50): 2
Matrices
Ingresado datos
Ing. Zegarra Henry
Matrices
Ingresando
datos a una
matriz.
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
i=0;
while( i<n_fil)
{
j=0;
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
Ing. Zegarra Henry
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
i=0;
while( i<n_fil)
{
j=0;
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
0,0
0,2
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
i=0;
while( i<n_fil)
{
j=0;
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
0,0
0,2
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
i=0;
while( i<n_fil)
{
j=0;
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
0,0
0,2
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
(VERDADERO)
while( i<n_fil)
{
j=0;
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
0,0
0,2
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
0,0
0,2
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
0<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
0,0
0,2
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
0<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
0<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
1<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
1<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
-1
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
1<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
-1
Matrices
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
2<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
-1
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
2<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][2] = 3
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
-1
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
2<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][2] = 3
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
-1
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
3<3 (FALSO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
-1
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
3<3 (FALSO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
-1
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
-1
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
-1
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
0<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
n_fil
n_col
0,0
0,212
0,1
1,0
1,2
1,1
Ing. Zegarra Henry
-1
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
0<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
Pos[1][0] = 11
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
0<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
Pos[1][0] = 11
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
1<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
Pos[1][0] = 11
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
1<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
Pos[1][0] = 11
Pos[1][1] = 100
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
1<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
Pos[1][0] = 11
Pos[1][1] = 100
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
2<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
Pos[1][0] = 11
Pos[1][1] = 100
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
2<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
Pos[1][0] = 11
Pos[1][1] = 100
Pos[1][1] = -11
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
2<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
Pos[1][0] = 11
Pos[1][1] = 100
Pos[1][1] = -11
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
3<3 (FALSO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
Pos[1][0] = 11
Pos[1][1] = 100
Pos[1][1] = -11
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
3<3 (FALSO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
Pos[1][0] = 11
Pos[1][1] = 100
Pos[1][1] = -11
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Ingresando datos a una matriz.
cout<<"Ingrese nmero de filas (Max. 50): ";
cin>>n_fil; // Nueva dimensin de fila
cout<<"Ingrese nmero de columnas (Max. 50):
";
cin>>n_col; // Nueva dimensin de columna
cout<<"Ingrese datos a la Matriz\n ";
i=0;
2<2 (FALSO)
while( i<n_fil)
{
j=0;
3<3 (FALSO)
while( j<n_col)
{
cout<<Pos["<<i<<"]["<<j<<"] = ";
cin>>mat1[i][j];
j++;
}
i++;
}
Ingrese nmero de filas (Max. 50): 2
Ingrese nmero de columnas (Max. 50): 3
Ingrese datos a la Matriz
Pos[0][0] = 12
Pos[0][1] = -1
Pos[0][1] = 3
Pos[1][0] = 11
Pos[1][1] = 100
Pos[1][1] = -11
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Ingrese nmero de filas (Max. 50): 2
Matrices
Imprimiendo datos
Ing. Zegarra Henry
Matrices
Imprimiendo datos
de una matriz.
Matrices
Imprimiendo la matriz
mat1 =
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
i=0;
while( i<n_fil)
{
j=0;
while( j<n_col)
{
cout<<["<<mat1[i][j]<<]\t";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
i=0;
while( i<n_fil)
{
j=0;
while( j<n_col)
{
cout<<["<<mat1[i][j]<<]\t";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
while( j<n_col)
{
cout<<["<<mat1[i][j]<<]\t";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
while( j<n_col)
{
cout<<["<<mat1[i][j]<<]\t";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
0<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<["<<mat1[i][j]<<]\t";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
0<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
0<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
1<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[-1]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
1<3
j=0;
(VERDADERO)
while( j<n_col)
{
000
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[-1]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
1<3
j=0;
(VERDADERO)
while( j<n_col)
{
00
cout<<\t["<<mat1[i][j]<<]";
0
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[-1]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
2<3
j=0;
while( j<n_col) (VERDADERO)
{
cout<<\t["<<mat1[i][j]<<]";
00 j++;
}0
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[-1]
[3]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
2<3
j=0;
(VERDADERO)
while( j<n_col)
{
000
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[-1]
[3]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
2<3
j=0;
(VERDADERO)
while( j<n_col)
{
00
cout<<\t["<<mat1[i][j]<<]";
0
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[-1]
[3]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
3<3 (FALSO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
00 j++;
}0
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
_
[-1]
[3]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
3<3 (FALSO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
_
[-1]
[3]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
0<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
3<3 (FALSO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}0
cout<<endl;
0
i++;
0
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
_
[-1]
[3]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
0 cout<<endl;
0 i++;
}
0
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
_
[-1]
[3]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
j=0;
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
_
[-1]
[3]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
0<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[11]
[-1]
[3]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
0<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[11]
[-1]
[3]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
0<3
j=0;
(VERDADERO)
while( j<n_col)
{
00
cout<<\t["<<mat1[i][j]<<]";
0
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[11]
[-1]
[3]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
1<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
00 j++;
}0
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[11]
[-1]
[3]
[100]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
1<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[11]
[-1]
[3]
[100]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
1<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[11]
[-1]
[3]
[100]
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
2<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
n_fil
n_col
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[11]
[-1]
[3]
[100] [-11]
n_fil
n_col
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
2<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[11]
[-1]
[3]
[100] [-11]
n_fil
n_col
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
2<3
j=0;
(VERDADERO)
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[11]
[-1]
[3]
[100] [-11]
n_fil
n_col
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
3<3 (FALSO)
j=0;
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[11]
[-1]
[3]
[100] [-11]
n_fil
n_col
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
3<3 (FALSO)
j=0;
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[11]
[-1]
[3]
[100] [-11]
n_fil
n_col
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
1<2
i=0;
while( i<n_fil) (VERDADERO)
{
3<3 (FALSO)
j=0;
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Matrices
Imprimiendo la matriz
mat1 =
[12]
[11]
[-1]
[3]
[100] [-11]
n_fil
n_col
Imprimiendo datos de una matriz.
cout<<Imprimiendo la matriz\n\nmat1
= \n;
i=0;
2<2 (FALSO)
while( i<n_fil)
{
3<3 (FALSO)
j=0;
while( j<n_col)
{
cout<<\t["<<mat1[i][j]<<]";
j++;
}
cout<<endl;
i++;
}
0,0
0,212
0,1
1,0
1,211
1,1
Ing. Zegarra Henry
-1
100
-11
Resumiendo
Ingresando dos Matrices
Visualizando dos Matrices
Matrices con Procedimientos
Primero: Debemos de declarar el
procedimiento con los siguientes datos
(matriz, fila, columna)
Segundo: Declarar las variables
restantes
que
utilizara
nuestro
procedimiento y definirlo con las
variables
declaradas
del
procedimiento.
Matrices con
Procedimient
os
Matrices con
Procedimient
os
Ingresando dos Matrices