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],C[3][3];
int indic1;
int indic2;
int multi;
int suma,promedio;
int maxi,mini;
int leer_2_matrices();
int ver_suma_2_matrices();    
int    promedio_matriz();
int mayor_y_sus_indices();
int menor_y_sus_indices();
int    transpuesta();
int inversa();

int    indice_matriz();    
     
int main ()
{ do{

    cout<<"*******MENU*******\n";
    cout<<"1.-leer_2_matrices  :\n";
    cout<<"2.-ver_suma_2_matrices :\n";
    cout<<"3.-promedio_matriz:\n";
    cout<<"4.-mayor_y_sus_indices:\n";
    cout<<"5.-menor_y_sus_indices:\n";
    cout<<"6.-transpuesta:\n";
    cout<<"7.-indice:\n";

    cout<<"ingrese una opcion: ";
    cin>> opcion;
    switch(opcion)
      {
         case 1: 
                 {
                  leer_2_matrices();

                  };break;
                  
              case 2:
                  {
                    ver_suma_2_matrices();    
                    
                  };break;
                  case 3:
                  {
                      promedio_matriz();
                  };break;
            case 4:
                  {
                      mayor_y_sus_indices();
                  };break; 
              case 5:
                  {
                      menor_y_sus_indices();
                  };break; 
              case 6: 
                 {
                      transpuesta();
                  };break;
                      case 7: 
                 {
                      indice_matriz();
                  };break;    
                       
          }
                    
      }while(opcion=!0);
          return 0 ;
      }
      
      
      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 <<"["<<i<<"]"<<"["<<j<<"]:"<<M[i][j]<<endl;
        }
    }
}
int    promedio_matriz()
{
    suma=0;
    for(i=1;i<=3;i++)
    {
    for(j=1;j<=3;j++)    
    suma=suma+M[i][j];         
    {
    promedio=suma/(i*j);
        }
    }cout<<"PROMEDIO DEL VECTOR :\n"<<promedio<<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 i:  "<< indic1<<endl;
    cout<< "el indice j:  "<< 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 i:  "<< indic1<<endl;
    cout<< "el indice j:  "<< indic2<<endl;

    cout<<"matriz_minimo :"<<mini<<endl;
}
int    transpuesta()
{
    for  (i=1;i<=3;i++)
    {
    for  (j=1;j<=3;j++)
        {
      cout<< "M["<<j<<"]["<<i<<"]= "<< M[j][i]<<endl;
        }
    }
    
}
int    indice_matriz()                     
{
    cout<<indic1<<endl;
    cout<<indic2<<endl;

}

10-07-18

bottom of page