LAB.3

#include<iostream>
#include<math.h>
using namespace std;
const int TAM_P=3, TAM_Q=3;
int i,j,D, min ,max , Elemento, Matriz[TAM_P][TAM_Q],A[TAM_P][TAM_Q],B[TAM_P][TAM_Q];
void ingreso ();
void lectura ();
int maximo ();
int minimo();
int suma();
int determinante();
int main()
{
// 1) DECLARACION

int opcion;
do
{
cout<<"\n *******************  MENU PRINCIPAL ********************* \n\n";
cout<<"1) LECTURA DE RESISTENCIAS \n ";
cout<<"2) IMPRESION O ESCRITURA DE LAS RESISTENCIAS \n ";
cout<<"3) PROCESAR LA RESISTENCIA MAXIMA \n ";
cout<<"4) PROCESAR LA RESISTENCIA MINIMA \n ";
cout<<"5) SUMA DE LOS ELEMENTOS DE LA MATRIZ \n ";
cout<<"6) DETERMINANTE DE UNA MATRIZ\n ";
cout<<" DIGITE <0> PARA SALIR \n\n ";
cout<<"********************************************** \n\n";
cout<<"  INGRESE UNA OPCION : ";  cin>>opcion;


switch (opcion)
{
  case 1:
   {
    cout<<"\n ************** LECTURA DE RESISTENCIAS ****************\n\n";
    ingreso ();
    cout<<endl;
    cout<<" ********************************************* \n\n";
   }//FIN DEL CASO 1
   break;
 
   case 2:
   {
    cout<<"\n ************ IMPRESION O ESCRITURA DE LAS RESISTENCIAS ***********\n\n";
    lectura ();
    cout<<endl;
    cout<<" ************************************************ \n\n";
   }//FIN DEL CASO 2
  break;

  case 3:
  {   
    cout<<"\n *************** PROCESAR LA RESISTENCIA MAXIMA ****************\n\n";
    maximo ();
    cout<<endl;
    cout<<"\n *************************************************** \n\n";
  }//FIN DEL CASO 3
  break;

   case 4:
  {  
    cout<<"\n ************** PROCESAR LA MINIMA RESISTENCIA ****************\n\n";
    minimo();
    cout<<endl;
    cout<<"\n ************************************************* \n\n";
  }//FIN DEL CASO 4

  case 5:
  {  
  cout<<"\n ************ SUMA DE LOS ELEMENTOS DE LA MATRIZ ************\n";
  suma();
  cout<<endl;
  cout<<"\n ********************************************* \n\n";
  }//FIN DEL CASO 5
  break;

  case 6:
  {
  cout<<"\n ************ LA DETERMINANTE DE UNA MATRIZ ************\n\n";
  determinante();
  cout<<endl;
  cout<<endl;
  cout<<" ************************************************** \n\n";
  }//FIN DEL CASO 6

  
  break;
} // FIN DEL SWITCH
}
while (opcion !=0);

cout<<endl; cout<<"\n";
system("pause");
return 0;
} // FIN DEL PROGRAMA

//ZONA DE DESARROLLO

void ingreso ()
{
    for (i=1;i<=TAM_P;i++)
    for (j=1;j<=TAM_Q;j++)
    {
    cout<<" INGRESE EL ELEMENTO P["<<i<<","<<j<<"]= ";cin>> Matriz[i][j];
    }
}

void lectura ()
{
    for (i=1;i<=TAM_P;i++)
    for (j=1;j<=TAM_Q;j++)
  
     cout<<" EL ELEMENTO P["<<i<<","<<j<<"] : "<< Matriz[i][j]<<endl; 
  
}

int maximo ()
{
    int max=0;
    for (i=1;i<=TAM_P;i++)
    for (j=1;j<=TAM_Q;j++)
    {
        if(Matriz[i][j]>max)
        max = Matriz[i][j];
    }
    cout<<" EL ELEMENTO MAXIMO DE LA MATRIZ ES : "<<max;

}

int minimo ()
{
    int min=1000;
    for (i=1;i<=TAM_P;i++)
    for (j=1;j<=TAM_Q;j++)
    {
        if(Matriz[i][j]<min)
        min = Matriz[i][j];
    }
    cout<<" EL ELEMENTO MINIMO DE LA MATRIZ ES : "<<min;
}

int suma ()
{
     int suma =0;
     for (i=1;i<=TAM_Q;i++)
     for (j=1;j<=TAM_P;j++)
     suma=suma+Matriz[i][j];
     cout<<" \n ----------------------------------------------------\n";
     cout<<"\n SUMA DE ELEMENTOS DE LA MATRIZ ES :"<<suma<<endl;
}

int determinante()
{
  D=((Matriz[1][1]*Matriz[2][2]*Matriz[3][3])+(Matriz[1][2]*Matriz[2][3]*Matriz[3][1])+(Matriz[1][3]*Matriz[2][1]*Matriz[3][2])-(Matriz[3][1]*Matriz[2][2]*Matriz[1][3])-(Matriz[3][2]*Matriz[2][3]*Matriz[1][1])-(Matriz[3][3]*Matriz[2][1]*Matriz[1][2]));
  cout<<endl;
  cout<<" LA DETERMINANTES ES :"<<D<<endl;

}

No hay comentarios.:

Publicar un comentario