top of page

#include <iostream>
#include <math.h>
using namespace std;
using namespace std ;
int opcion;
int V[20];
int M[4][4];
int i,j;
int A[3][3],B[3][3];
int indic1;
int indic2;
int maxi,mini;
int    leer_matriz();
int    ver_matriz();
int leer_2_matrices();
int ver_suma_2_matrices();    
int    transpuesta();
int mayor_y_sus_indices();
int menor_y_sus_indices();
int    indice_matriz();    
     
int main ()
{ do{

    cout<<"*******MENU*******\n";
    cout<<"1.-leer_matriz  :\n";
    cout<<"2.-ver_matriz :\n";
    cout<<"3.-leer_2 matrices:\n";
    cout<<"4.-ver_suma_2_matrices:\n";
    cout<<"5.-transpuesta:\n";
    cout<<"6.-mayor y sus indices:\n";
    cout<<"7.-menor y sus indices:\n";
    cout<<"8.-indice_matriz:\n";
    cout<<"ingrese una opcion: ";
    cin>> opcion;
    switch(opcion)
      {
         case 1: 
                 {
                      leer_matriz();
                  };break;
                  
              case 2:
                  {
                      ver_matriz();
                  };break;
            
            case 3:
                  {
                        leer_2_matrices();
                  };break;      
             case 4:
             {
                     ver_suma_2_matrices();    
                 };break;
             case 5: 
                 {
                      transpuesta();
                  };break;
              case 6:
                  {
                      mayor_y_sus_indices();
                  };break;
            case 7:
                  {
                      menor_y_sus_indices();
                  };break; 
              case 8: 
                 {
                      indice_matriz();
                  };break;    
             
                          
          }
                    
      }while(opcion=!0);
          return 0 ;
      }
/////////ZONA DE FUNCIONES////////////////////////////////////////////////////////////////////////////////
int    leer_matriz()
{
    for  (i=1;i<=3;i++)
    {
    for  (j=1;j<=3;j++)
            {
    cout<< "M["<<i<<"]["<<j<<"]= "; cin>> M[i][j];
           }    
           
    }

}

int    ver_matriz()
{
    for  (i=1;i<=3;i++)
    {
    for  (j=1;j<=3;j++)
    {
      cout<< "M["<<i<<"]["<<j<<"]= "<< M[i][j];
    }
    cout<<endl;
    }
}
int leer_2_matrices()
{
    for  (i=1;i<=3;i++)
    {
    for  (j=1;j<=3;j++)
    {
               cout<< "A["<<i<<"]["<<j<<"]= "; cin>> A[i][j];
    }
    }
    for  (i=1;i<=3;i++)
    {
        for  (j=1;j<=3;j++)
         {
                 cout<< "B["<<i<<"]["<<j<<"]= "; cin>> B[i][j];
           }
    }
        cout<<endl;

}


int ver_suma_2_matrices()    
{
    for  (i=1;i<=3;i++)
   {
    for  (j=1;j<=3;j++)
   
        {
            M[i][j]= A[i][j]+B[i][j];
            cout <<"\t"<<" M=["<<i<<"]"<<"["<<j<<"]:"<<M[i][j];
        }
        cout<<endl;
    }
}
    
    
int    transpuesta()
{
    for  (i=1;i<=3;i++)
    {
    for  (j=1;j<=3;j++)
        {
      cout<< "M["<<j<<"]["<<i<<"]= "<< M[j][i]<<endl;
        }
    }
    
}
int mayor_y_sus_indices()
{
    maxi=M[1][1];
    for  (i=1;i<=3;i++)
    {
    for  (j=1;j<=3;j++)    
        {
        if (M[i][j]>maxi)
            {
         maxi=M[i][j]; 
          indic1= i;
             indic2= j;
            }
        }
    }
    cout<< "el indice es:  "<< indic1<<endl;
    cout<< "el indice es:  "<< indic2<<endl;
    cout<<"matriz_maximo :"<<maxi<<endl;
}
int menor_y_sus_indices()
{
    mini=M[1][1];
              for  (i=1;i<=3;i++)
      {
              for  (j=1;j<=3;j++)    
         {
                  if (M[i][j]<mini)
                {
                 mini=M[i][j]; 
                  indic1= i;
                  indic2= j;
                   }
        }
    }
    cout<< "el indice es:  "<< indic1<<endl;
    cout<< "el indice es:  "<< indic2<<endl;

    cout<<"matriz_minimo :"<<mini<<endl;
}
int    indice_matriz()                    
{
    cout<<indic1<<endl;
    cout<<indic2<<endl;

}

bottom of page