
LENGUAJE DE PROGRAMACIÓN
alumno: tenorio diaz ney eduardo

TAREA DEL EQUIPO 7
# include <iostream>
# include <math.h>
# include <cstdlib>
using namespace std;
int opcion=0, i, j, SUMA, potencia;
int A[3][3], B[3][3], C[3][3];
float SUMAR;
void ASIGNAR();
void MOSTRAR();
void PROMEDIO();
void SUMARMATRICES();
void CUADRADA();
int main(){
do{
cout << " M E N U P R I N C I P A L D E M A T R I C E S "<< endl;
cout << " ----------------------------"<< endl;
cout << " [1] ASIGNAR VALORES A LA MATRIZ "<< endl;
cout << " [2] MOSTRAR LOS ELEMENTOS DE LA MATRIZ "<< endl;
cout << " [3] PROMEDIO DE LOS ELEMENTOS "<< endl;
cout << " [4] SUMA DE DOS MATRICES "<< endl;
cout << " [5] MATRIZ CUADRADA"<< endl;
cout << "\n INGRESE UNA OPCION <> 0 : "; cin>>opcion;
cout << " ----------------------------"<< endl;
switch (opcion){
case 1:{
cout << " [1] ASIGNAR VALORES A LA MATRIZ "<< endl;
cout << " ----------------------------"<< endl;
ASIGNAR();
cout << " ----------------------------"<< endl;
break;
}
case 2:{
cout << " [2] MOSTRAR LOS ELEMENTOS DE LA MATRIZ "<< endl;
cout << " ----------------------------"<< endl;
MOSTRAR();
cout << "\n ----------------------------"<< endl;
break;
}
case 3:{
cout << " [3] PROMEDIO DE LOS ELEMENTOS "<< endl;
cout << " ----------------------------"<< endl;
PROMEDIO();
cout << " ----------------------------"<< endl;
break;
}
case 4:{
cout << " [4] SUMA DE DOS MATRICES "<< endl;
cout << " ----------------------------"<< endl;
SUMARMATRICES();
cout << " ----------------------------"<< endl;
break;
}
case 5:{
cout << " [5] MATRIZ CUADRADA "<< endl;
cout << " ----------------------------"<< endl;
CUADRADA();
cout << " ----------------------------"<< endl;
break;
}
}
} while (opcion!=0);
cout<<rand();
}
void ASIGNAR()
{
cout<<"LLENAR DE ELEMENTOS DE LA MATRIZ A[3][3] "<< endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" A["<<i<<"]"<<"["<<j<<"] = ";
cin>>A[i][j];
}
}
void MOSTRAR()
{
cout<<"MOSTRAR LOS ELEMENTOS DE LA MATRIZ A[3][3] "<< endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" A["<<i<<"]"<<"["<<j<<"] = "<<A[i][j]<< endl;
}
}
void PROMEDIO()
{
SUMAR = 0;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
SUMAR = SUMAR + A[i][j];
}
cout<<"PROMEDIO DE LOS ELEMENTOS DE LA MATRIZ A["<<"3"<<"]"<<"["<<"3"<<"] = "<<SUMAR/9<<endl;
}
void SUMARMATRICES()
{
cout<<"LLENADO DE ELEMENTOS DE LA MATRIZ A[3][3] y B[3][3] "<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
A[i][j]= rand()%20;
B[i][j]= rand()%20;
}
cout<<endl;
cout << " ----------------------------"<< endl;
cout<<"MOSTRAR LOS ELEMENTOS DE LA MATRIZ A[3][3]"<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" A["<<i<<"]"<<"["<<j<<"] = "<<A[i][j]<<endl;
}
cout<<endl;
cout << " ----------------------------"<< endl;
cout<<"MOSTRAR LOS ELEMENTOS DE LA MATRIZ B[3][3]"<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" B["<<i<<"]"<<"["<<j<<"] = "<<B[i][j]<<endl;
}
cout<<endl;
cout << " ----------------------------"<< endl;
cout<<"SUMA DE MATRICES: A[3][3] + B[3][3]"<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
C[i][j] = A[i][j] + B[i][j];
}
cout<<endl;
cout << " ----------------------------"<< endl;
cout<<"RESULTADO DE LA SUMA DE MATRICES: C[3][3]"<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" C["<<i<<"]"<<"["<<j<<"] = "<<C[i][j]<<endl;
}
}
void CUADRADA()
{
cout<<"POTENCIA DE LA MATRIZ A[3][3] "<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
A[i][j] = rand()%20;
}
cout<<endl;
cout << " ----------------------------"<< endl;
cout<<"MOSTRAR LOS ELEMENTOS DE LA MATRIZ A[3][3]"<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" A["<<i<<"]"<<"["<<j<<"] = "<<A[i][j]<<endl;
}
cout<<endl;
cout<<"POTENCIA: ";cin>>potencia;
cout << " ----------------------------"<< endl;
cout<<endl;
cout<<"RESULTADO DE LA POTENCIA: A[3][3]"<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" A["<<i<<"]"<<"["<<j<<"] = "<<pow(A[i][j],potencia)<<endl;
}
}





UNION DE LOS TRABAJOS EN EQUIPO DE MATRICES
# include <iostream>
# include <math.h>
# include <cstdlib>
using namespace std;
int opcion=0, i, j, k, n, X, Y, a, b, c, d, minimo, maximo, SUMA, potencia;
int A[3][3], B[3][3], C[3][3], transpuesta[3][3], matriz[3][3], D[100][100];
float SUMAR;
bool nula;
void ASIGNAR();
void MOSTRAR();
void PROMEDIO();
void SUMARMATRICES();
void PRODUCTO();
void DETERMINANTE();
void INVERSA();
void Transponer();
void IDENTIDAD();
void MENORESCOMPLEMENTARIOS();
void CUADRADA();
void MAXMIN();
int main(){
do{
cout << " M E N U P R I N C I P A L D E M A T R I C E S "<< endl;
cout << " ----------------------------"<< endl;
cout << " [1] ASIGNAR VALORES A LA MATRIZ "<< endl;
cout << " [2] MOSTRAR LOS ELEMENTOS DE LA MATRIZ "<< endl;
cout << " [3] PROMEDIO DE LOS ELEMENTOS "<< endl;
cout << " [4] SUMA DE DOS MATRICES "<< endl;
cout << " [5] PRODUCTO DE DOS MATRICES "<< endl;
cout << " [6] DETERMINATE DE UNA MATRIZ "<< endl;
cout << " [7] INVERSA DE UNA MATRIZ "<< endl;
cout << " [8] TRANSPUESTA DE UNA MATRIZ "<< endl;
cout << " [9] IDENTIDAD DE MATRICES "<< endl;
cout << " [10] MENORES COMPLEMENTARIOS DE LA MATRIZ "<< endl;
cout << " [11] MATRIZ CUADRADA "<< endl;
cout << " [12] VALOR MÁXIMO Y MÍNIMO DE UNA MATRIZ "<< endl;
cout << "\n INGRESE UNA OPCION <> 0 : "; cin>>opcion;
cout << " ----------------------------"<< endl;
switch (opcion){
case 1:{
cout << " [1] ASIGNAR VALORES A LA MATRIZ "<< endl;
cout << " ----------------------------"<< endl;
ASIGNAR();
cout << " ----------------------------"<< endl;
break;
}
case 2:{
cout << " [2] MOSTRAR LOS ELEMENTOS DE LA MATRIZ "<< endl;
cout << " ----------------------------"<< endl;
MOSTRAR();
cout << "\n ----------------------------"<< endl;
break;
}
case 3:{
cout << " [3] PROMEDIO DE LOS ELEMENTOS "<< endl;
cout << " ----------------------------"<< endl;
PROMEDIO();
cout << " ----------------------------"<< endl;
break;
}
case 4:{
cout << " [4] SUMA DE DOS MATRICES "<< endl;
cout << " ----------------------------"<< endl;
SUMARMATRICES();
cout << " ----------------------------"<< endl;
break;
}
case 5:{
cout << " [5] PRODUCTO DE DOS MATRICES "<< endl;
cout << " ----------------------------"<< endl;
PRODUCTO();
cout << " ----------------------------"<< endl;
break;
}
case 6:{
cout << " [6] DETERMINATE DE UNA MATRIZ "<< endl;
cout << " ----------------------------"<< endl;
DETERMINANTE();
cout << " ----------------------------"<< endl;
break;
}
case7:{
cout << " [7] INVERSA DE UNA MATRIZ "<< endl;
cout << " ----------------------------"<< endl;
INVERSA();
cout << " ----------------------------"<< endl;
break;
}
case 8:{
cout << " [8] TRANSPUESTA DE UNA MATRIZ "<< endl;
cout << " ----------------------------"<< endl;
Transponer();
cout << " ----------------------------"<< endl;
break;
}
case 9:{
cout << " [9] IDENTIDAD DE MATRICES "<< endl;
cout << " ----------------------------"<< endl;
IDENTIDAD();
cout << " ----------------------------"<< endl;
break;
}
case 10:{
cout << " [10] MENORES COMPLEMENTARIOS DE LA MATRIZ "<< endl;
cout << " ----------------------------"<< endl;
MENORESCOMPLEMENTARIOS();
cout << " ----------------------------"<< endl;
break;
}
case 11:{
cout << " [7] MATRIZ CUADRADA "<< endl;
cout << " ----------------------------"<< endl;
CUADRADA();
cout << " ----------------------------"<< endl;
break;
}
case 12:{
cout << " [12] VALOR MÁXIMO Y MÍNIMO DE UNA MATRIZ "<< endl;
cout << " ----------------------------"<< endl;
MAXMIN();
cout << " ----------------------------"<< endl;
break;
}
}
} while (opcion!=0);
cout<<rand();
}
void ASIGNAR()
{
cout<<"LLENAR DE ELEMENTOS DE LA MATRIZ A[3][3] "<< endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" A["<<i<<"]"<<"["<<j<<"] = ";
cin>>A[i][j];
}
}
void MOSTRAR()
{
cout<<"MOSTRAR LOS ELEMENTOS DE LA MATRIZ A[3][3] "<< endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" A["<<i<<"]"<<"["<<j<<"] = "<<A[i][j]<< endl;
}
}
void PROMEDIO()
{
SUMAR = 0;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
SUMAR = SUMAR + A[i][j];
}
cout<<"PROMEDIO DE LOS ELEMENTOS DE LA MATRIZ A["<<"3"<<"]"<<"["<<"3"<<"] = "<<SUMAR/9<<endl;
}
void SUMARMATRICES()
{
cout<<"LLENADO DE ELEMENTOS DE LA MATRIZ A[3][3] y B[3][3] "<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
A[i][j]= rand()%20;
B[i][j]= rand()%20;
}
cout<<endl;
cout << " ----------------------------"<< endl;
cout<<"MOSTRAR LOS ELEMENTOS DE LA MATRIZ A[3][3]"<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" A["<<i<<"]"<<"["<<j<<"] = "<<A[i][j]<<endl;
}
cout<<endl;
cout << " ----------------------------"<< endl;
cout<<"MOSTRAR LOS ELEMENTOS DE LA MATRIZ B[3][3]"<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" B["<<i<<"]"<<"["<<j<<"] = "<<B[i][j]<<endl;
}
cout<<endl;
cout << " ----------------------------"<< endl;
cout<<"SUMA DE MATRICES: A[3][3] + B[3][3]"<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
C[i][j] = A[i][j] + B[i][j];
}
cout<<endl;
cout << " ----------------------------"<< endl;
cout<<"RESULTADO DE LA SUMA DE MATRICES: C[3][3]"<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" C["<<i<<"]"<<"["<<j<<"] = "<<C[i][j]<<endl;
}
}
void PRODUCTO()
{
cout << "PRODUCTO DE LAS MATRICES A[3][3] y B[3][3]" << endl;
cout << " ----------------------------"<< endl;
int producto[3][3]; // Matriz para almacenar el resultado del producto
// Calcular el producto de las matrices A y B
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
producto[i][j] = 0;
for (int k = 0; k < 3; k++) {
producto[i][j] += A[i][k] * B[k][j];
}
}
}
// Mostrar el resultado del producto
cout << "RESULTADO DEL PRODUCTO: C[3][3]" << endl;
cout << " ----------------------------"<< endl;
for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++)
{
cout << " C[" << i << "][" << j << "] = " << producto[i][j] << endl;
}
}
void DETERMINANTE()
{
int det = 0;
for (int i = 0; i < FILAS; ++i)
{
int product = 1;
for (int j = 0; j < FILAS; ++j)
{
product *= A[(i + j) % FILAS][j];
}
det += product;
}
for (int i = 0; i < FILAS; ++i)
{
int product = 1;
for (int j = 0; j < FILAS; ++j)
{
product *= A[(FILAS - 1) - (i + j) % FILAS][j];
}
det -= product;
}
cout << "La determinante de la matriz A[][] es: " << det << endl;
}
void INVERSA()
{
float det = 0;
float adj[3][3];
float inv[3][3];
// Calculando el determinante de la matriz A
for (i = 1; i <= 3; i++)
det = det + (A[1][i] * (A[2][(i % 3) + 1] * A[3][(i % 3) + 2] - A[2][(i % 3) + 2] * A[3][(i % 3) + 1]));
{
cout<<"La determiante es: "<<det<<endl;
cout<<endl;
}
// Calculando la matriz adjunta
for (i = 1; i <= 3; i++)
for (j = 1; j <= 3; j++)
adj[i][j] = ((A[(j % 3) + 1][(i % 3) + 1] * A[(j % 3) + 2][(i % 3) + 2]) - (A[(j % 3) + 1][(i % 3) + 2] * A[(j % 3) + 2][(i % 3) + 1]));
{
cout<<"la matriz adjunta es: "<<adj[i][j]<<endl;
cout<<endl;
}
// Calculando la inversa
for (i = 1; i <= 3; i++)
for (j = 1; j <= 3; j++)
inv[i][j] = adj[j][i] / det;
// Mostrando la matriz inversa
cout << "Matriz Inversa:" << endl;
for (i = 1; i <= 3; i++) {
for (j = 1; j <= 3; j++)
cout << inv[i][j] << "\t";
cout << endl;
}
}
void Transponer()
{
cout << "Transponer la matriz A[3][3] \n";
for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++)
transpuesta[i][j] = A[j][i];
cout << "La matriz transpuesta de A[3][3] es \n";
for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++)
cout << "Transpuesta[" << i << "][" << j << "] = " << transpuesta[i][j] << endl;
}
void IDENTIDAD()
{
cout << "Matriz Identidad 3x3:" << endl;
for (i = 1; i <= 3; i++)
{
for (j = 1; j <= 3; j++)
{
if (i == j)
cout << " 1 ";
else
cout << " 0 ";
}
cout << endl;
}
}
void MENORESCOMPLEMENTARIOS()
{
cout << "CALCULANDO MENORES COMPLEMENTARIOS DE LA MATRIZ A[4][4]" << endl;
cout << " ----------------------------" << endl;
// Cálculo de menores complementarios de la matriz A[4][4]...
}
void CUADRADA()
{
cout<<"POTENCIA DE LA MATRIZ A[3][3] "<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
A[i][j] = rand()%20;
}
cout<<endl;
cout << " ----------------------------"<< endl;
cout<<"MOSTRAR LOS ELEMENTOS DE LA MATRIZ A[3][3]"<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" A["<<i<<"]"<<"["<<j<<"] = "<<A[i][j]<<endl;
}
cout<<endl;
cout<<"POTENCIA: ";cin>>potencia;
cout << " ----------------------------"<< endl;
cout<<endl;
cout<<"RESULTADO DE LA POTENCIA: A[3][3]"<<endl;
cout << " ----------------------------"<< endl;
for(i=1; i<=3; i++)
for(j=1; j<=3; j++)
{
cout<<" A["<<i<<"]"<<"["<<j<<"] = "<<pow(A[i][j],potencia)<<endl;
}
}
void MAXMIN()
{
cout << "Ingrese la cantidad de filas de la matriz: ";
cin >> X;
cout << "Ingrese la cantidad de columnas de la matriz: ";
cin >> Y;
cout << "Ingrese los elementos de la matriz:" << endl;
for (i = 1; i <= X; i++)
{
for (j = 1; j <= Y; j++)
{
cout << " D[" << i << "]"
<< "[" << j << "] = ";
cin >> D[i][j];
}
}
minimo = 100000000;
for (i = 1; i <= X; i++)
{
for (j = 1; j <= Y; j++)
{
if (D[i][j] < minimo)
{
minimo = D[i][j];
a = i;
b = j;
}
}
}
maximo = 0;
for (i = 1; i <= X; ++i)
{
for (j = 1; j <= Y; ++j)
{
if (D[i][j] > maximo)
{
maximo = D[i][j];
c = i;
d = j;
}
}
}
nula = true;
for (i = 1; i <= X; ++i)
{
for (j = 1; j <= Y; ++j)
{
if (D[i][j] != 0)
{
nula = false;
}
}
}
cout << "\nEl valor minimo de la matriz D[][] es: " << minimo << " en la posicion: D[" << a << "][" << b << "]\n";
cout << "\nEl valor maximo de la matriz D[][] es: " << maximo << " en la posicion: D[" << c << "][" << d << "]";
if (nula == false){
cout << "\nLa matriz no es nula por que tiene valores diferentes de cero ";
} else {
cout << "\nLa matriz es nula por que todos sus valores son cero ";
}
}




