top of page

LABORATORIO 4

MATRIZ

  MENU

#include <iostream>
#include <math.h>
using namespace std;
int i,j;
int M[3][3],B[3][3],A[3][3];
int  leer_matriz(),ver_matriz(),leer_dos_matrices(),sumar_dos_matrices();
int opcion;
int main()

{

do{
        
 cout<<"MENU  \n";
 cout<<" 1.- identidad \n";
 cout<<" 2.- suma 2 matrices  \n";
 cout<<"ingrese opcion : \n";
 cin>>opcion;
 
 switch(opcion)
 
 {
 
    case 1:
    {
        
    leer_matriz();        
     };break;
     
     case 2:
    {
        
    ver_matriz();        
     };break;
          
     case 3:
    {
        
    leer_dos_matrices();        
     };break;
          
     case 4:
    {
        
    sumar_dos_matrices();        
     };break;
          


} //fin switch
}while(opcion=!0);
 //system("pause");
 return 0;
} //fin programa

int leer_matriz()
{

for(i=1;i<=3;i++)
for(j=1;j<=3;j++)
{
cout<<"M["<<i<<"]["<<j<<"]= "; cin>>M[i][j];
//cout<<"   M[i][j]= "<<M[i][j]<<endl;
}
}

int ver_matriz()
{

for(i=1;i<=3;i++)
for(j=1;j<=3;j++)
{
cout<<"   M[i][j]= "<<M[i][j]<<endl;
}
cout<<endl;
}

int leer_dos_matrices() 
{
cout<<"MATRIZ A[i][j] "<<A[i][j]<<endl;
for(i=1;i<=3;i++)
for(j=1;j<=3;j++) 
cin>>A[i][j];

cout<<"MATRIZ B[i][j]: "<<A[i][j]<<endl;
for(i=1;i<=3;i++)
for(j=1;j<=3;j++)
cin>>B[i][j]; 
    
}

int sumar_dos_matrices() 
{
    
for(i=1;i<=3;i++)
for(j=1;j<=3;j++) 
 M[i][j]=A[i][j]+B[i][j];
}

© 2023 hecho por Erick Aybar . Orgullosamente creado con Wix.com

  • Facebook Black Round
  • Instagram Black Round
  • Twitter Black Round
  • Vimeo Black Round
bottom of page