LAB-3

#include<iostream>
#include<math.h>
using namespace std;
int a, b, c, n;

//ZONA DE DECLARACION DE LOS VECTORES

const int TAM_N=4, TAM_M=4;
int suma, i, j, Elemento, max, Matriz[TAM_N][TAM_M], A[TAM_N][TAM_M], B[TAM_N][TAM_M];

int main ()
{//1)DECLARACION
int opcion;
do
{
cout<<"*********MENU DE MATRICES**********\n\n";
cout<<"1)LECTURA UNA MATRIZ \n";
cout<<"2)IMPRESION O ESCRITURA DE LA MATRIZ \n";
cout<<"3)PROCESAR EL MAXIMO DE LOS ELEMENTOS \n";
cout<<"4)PROCESAR EL MAXIMO DE LOS ELEMENTOS \n";
cout<<"5)MULTIPLICACION DE MATRICES \n";
cout<<"       DIGITE <0> PARA SALIR \n\n";
cout<<"*************\n\n";
cout<<"   ELIJA UNA OPCION : "; cin>>opcion;
    //2)ASIGNACION
    switch (opcion)
    {
    case 1:
       {
       cout<<"******* LECTURA UNA MATRIZ******\n\n";
       for (i=1; i<=TAM_N; i++)
       for (j=1; j<=TAM_M; j++)
        {
       cout<<"INGRESE EL ELEMENTO M[ "<<i<<" ,"<<j<<"] = "; cin>>Matriz[i][j];
       }
       cout<<endl;
       cout<<"*************************************\n\n";
    } //FIN DEL CASO 1
     break;    
  case 2:
          {
          cout<<"*******IMPRESION O ESCRITURA DE LA MATRIZ*****\n\n";
         
          for (i=1; i<=TAM_N; i++)
          for (j=1; j<=TAM_M; j++)
          {
              cout<<"ELEMENTO M["<<i<<","<<j<<"] = "<<Matriz[i][j]<<endl;
              }
 
           cout<<endl;
   
         cout<<"*************************************\n\n";
  }      //FIN DEL CASO 2
    break;

    case 3:
      {
           cout<<"********* PROCESAR EL MAXIMO DE LOS ELEMENTOS ************\n";
           int max = 0;
           for(i=1; i<=TAM_N; i++)
            for(j=1; j<=TAM_M; j++)
            {
            if(Matriz[i][j]>max)
            max = Matriz[i][j];
           
            }
           //RESULTADO
           cout<<"EL MAXIMO DE LOS ELEMENTOS DE LA MATRIZ ES: "<<max;
           cout<<endl;
           cout<<"**********************\n\n";
               
        //FIN DEL CASO 3
      }
   break;
    case 4:
        {
               cout<<"******* PROCESAR EL MINIMO DE LOS ELEMENTOS******\n\n";
       int min=100;
       for (i=1; i<=TAM_N; i++)
       for (j=1; j<=TAM_M; j++)
       {
           if(Matriz[i][j]<min)
           min= Matriz[i][j];
       }
       //RESULTADO
       cout <<"INGRESE EL MINIMO DE LOS ELEMENTOS DE LA MATRIZ ES: "<<min;
       cout<<endl;
           cout<<"*************************************\n\n";
       
   //FIN DEL CASO 4

      }    
      break;
         case 5:
      {
 int i, j, a[6] [6], b [6] [6], c [6] [6], d [6] [6];
 cout << "" << endl;
 cout << "ingresa los Datos de la matriz 1" << endl;
 cout << "" << endl;
 for (i = 0; i <2; i ++)
 {
 cout << "Fila" << (i + 1) << endl;
for (j = 0; j <2; j ++)
{
cout << "Columna "<< (j + 1) <<" -> ";
 cin >> a [i] [j];
 }
 }
 cout << "ingresa los Datos de la matriz 2" << endl;
  cout << "" << endl;
  for (i = 0; i <2; i ++)
{
cout << "Fila" << (i + 1) << endl;
 for (j = 0; j <2; j ++)
{
cout << "Columna" << (j + 1) << "->";
 cin >> b [i] [j];
  }
  } // 1 a instancia de parte
  for (i = 0; i <2; i ++)
  { for ( j = 0; j <2; j ++)
   { c
    [i] [j] = a [i] [j] * b [j] [0];
  }
  }
  //2da Parte
  for (i = 0; i <2 ; i ++)
  {
  for (j = 0; j <2; j ++)
  {
  d [i] [j] = a [i] [j] * b [j] [1];
  }
   }
   cout << "" << endl;
    cout << "" << endl;
     cout << "" << endl;
      for (i = 0; i <2; i ++)
      {
cout << "" << "" << (c [i] [ 0] + c [i] [1]) << "";
cout << "" << "" << (d [i] [0] + d [i] [1]) << "";
cout << "" << endl;
      }
      break;
     
  }
   
}// FIN DE SWITCH
 }
while (opcion !=0);  
    cout<<endl;cout<<"\n";
    system("pause");
    return 0;
}//FIN DEL PROGRAMA

No hay comentarios:

Publicar un comentario