martes, 22 de octubre de 2013

1 parcial

1 parcial

2 parcial

using namespace std;
#include <iostream>
#include <conio.h>
#include <math.h>
#include <iomanip>
#define N 4
    int opcion,n,i,j,k;
    int G[4][4], H[4][4], K[4][4],Y[4][4];
    int A[4][4], B[4][4], C[4][4];
    int P[5][5],Q[5][5];
int main()
{
do
{
    cout << setw(57) << "************* MENU *************\n" << endl;
    cout << "1) PROBLEMA NUMERO 1" << endl;
    cout << "2) PROBLEMA NUMERO 2" << endl;
    cout << "3) PROBLEMA NUMERO 3" << endl;
    cout << "4) PROBLEMA NUMERO 4" << endl;
    cout << "POR FAVOR  INGRESE UNA OPCION / <0> PARA SALIR: "; cin>> opcion;
    cout << "\n\n";
    switch(opcion)
    {
    case 1:
         {
                 
         cout.setf(ios::fixed);
         cout.precision(3);
         cout << "********************************************************************************\n\n";
         cout << setw(50) << "PROBLEMA NUMERO 1" << endl;
         cout << setw(50) << "=================";
         cout << "\n\n";

cout<<"\n\n INGRESE EL TAMAÑO DE LA MATRIZ: ";cin>>n;

for(i =0; i < n; i++)
for(j =0; j < n;j++)
   {
     cout<<"\n Ingrese el valor del elemento: P["<<i+1<<"]["<<j+1<<"]= ";
     cin>>P[i][j];
   }


// Lectura de la Matriz P[m,n]
for(i =0; i < n; i++)
for(j =0; j < n;j++)
   {
     cout<<"\n P["<<i+1<<"]["<<j+1<<"]=  ";
     cout<<P[i][j];
   }

for(i =0; i < n; i++)
for(j =0; j < n; j++)
   {
       Q[i][j]= P[i][j];
   }

for(i=0; i < n; i++)
for(j =0; j < n; j++)
   {
     cout<<"\n Q["<<i+1<<"]["<<j+1<<"]=  ";
     cout<<Q[i][j];
   }
#define N 4
{
int I;
double max;
double min;
int numeros[N];
int i;
int maximo, minimo;
// INICIALIZO
minimo=1000;
maximo=0;
// LECTURA DE LOS ELEMENTOS VECTOR
for(i=0;i<N;i++)
{      cout<<"\n Ingrese el numero "<<i+1<<" = ";  cin>>(numeros[i]);}
// PROCESO calcula el MAXIMO Y EL MINIMO
for(i=0;i<N;i++)
         {
if(numeros[i]<minimo)
minimo=numeros[i];
if(numeros[i]>maximo)
maximo=numeros[i];
  }
cout<<"\n";
cout<<"EL MAXIMO  ES : "<<maximo;
cout<<"\n";
cout<<"EL MINIMO  ES : "<<minimo;
cout<<"\n";
//calculo  maximo
cout<<"ingresar =";cin>>I;
for(max=0;max<0;max++)
{   max=maximo;   }
cout<<" maximo es=\n"<<max<<",";
cout<< "FIN \n";

cout<<"ingresar =";cin>>I;
for(min=0;min<0;min++)
{     min=minimo;   }
cout <<"\n";
cout<<" minimo es=\n"<<min<<",";
cout<< "FIN \n";
getch();
}


getch();

                     
         }
    break;
    case 2:
         {
                  int i,j,k,n;
                  float x;
                  n=4;
                  int E[4][4],T[4][4],U[4][4];
                  cout.setf(ios::fixed);
                  cout.precision(2);
                  cout << "********************************************************************************\n\n";
                  cout << setw(50) << "PROBLEMA NUMERO 2" << endl;
                  cout << setw(50) << "=================";
                  cout << "\n\n";
                  cout << "Escribir un programa que llene una matriz de 4 por 4 de valores aleatorios" << endl;
    for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
    {
    cout<<"\n Ingrese el valor del elemento: A["<<i+1<<"]["<<j+1<<"]= ";
    cin>>E[i][j] ;
    }


// Lectura de la Matriz A[m,n]
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n A["<<i+1<<"]["<<j+1<<"]=  ";
     cout<<E[i][j] ;
   }

// calcular el producto de los elementos de las matrices
//A  en C
       cout<<"\n SUMA DE COLUMNAS\n\n";

         for (i = 0; i < n; i++)
         for (j = 0; j < n; j++)
         {
         C[i][j] = E[i][j];
       }
// VER EL RESULTADO DEL PRODUCTO DE SUS ELEMENTOS

// Lectura de la Matriz C[m,n]
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n C["<<i+1<<"]= ";
     cout<<C[i][j] ;
   }
   cout<<"\n SUMA DE COLUMNAS\n\n";
 
         for (i = 0; i < n; i++)
         for (j = 0; j < n; j++)
         {
         U[i][j] = E[i][j];
       }
// VER EL RESULTADO DEL PRODUCTO DE SUS ELEMENTOS

// Lectura de la Matriz C[m,n]
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n U["<<j+1<<"]= ";
     cout<<U[i][j] ;
   }


system("pause");
return 0;
}


    break;
    case 3:
         {
                  cout.setf(ios::fixed);
                  cout.precision(3);
                  cout << "********************************************************************************\n\n";
                  cout << setw(50) << "PROBLEMA NUMERO 3" << endl;
                  cout << setw(50) << "=================";
                  cout << "\n\n";
                 
                 
                 
                 
       
         }
    case 4:
         {
                 int i,j,k,n,x;
                  n=3;
                  int G[3][3], H[3][3], Y[3][3], K[3][3];
                  cout.setf(ios::fixed);
                  cout.precision(3);
                  cout << "********************************************************************************\n\n";
                  cout << setw(50) << "PROBLEMA NUMERO 4" << endl;
                  cout << setw(50) << "=================";
                  cout << "\n\n";
                 
                  cout <<"SUMA DE LA MATRIZ" << endl;
                  cout <<"RESTA DE LA MATRIZ" << endl;
                  cout <<"INVERSA DE LA MATRIZ" << endl;
                  cout << "TRANSPUESTA DE LA MATRIZ" << endl;
                  cout << "POR FAVOR  INGRESE UNA OPCION / <0> PARA SALIR: "; cin>> opcion;
                  cout << "\n\n";
                  switch(opcion)
                  {
                   case 1:
                        {
cout<<setw(50)<<"CALCULO DE LA RESTA DE LA MATRIZ"<<endl;                    
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n Ingrese el valor del elemento: A["<<i+1<<"]["<<j+1<<"]= ";
     cin>>A[i][j] ;
   }

//MATRIZ B
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n Ingrese el valor del elemento: B["<<i+1<<"]["<<j+1<<"]= ";
     cin>>B[i][j] ;
   }


// Lectura de la Matriz A[m,n]
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n A["<<i+1<<"]["<<j+1<<"]=  ";
     cout<<A[i][j] ;
   }

// Lectura de la Matriz B[m,n]
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n B["<<i+1<<"]["<<j+1<<"]=  ";
     cout<<B[i][j] ;
   }

// calcular el producto de los elementos de las matrices
//A y B en C

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
C[i][j] = A[i][j] + B[j][j];
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n C["<<i+1<<"]["<<j+1<<"]=  ";
cout<<C[i][j] ;
}
getch();
}      
 case 2:
     
{        
cout<<setw(50)<<"CALCULO DE LA RESTA DE LA MATRIZ"<<endl;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n Ingrese el valor del elemento: A["<<i+1<<"]["<<j+1<<"]= ";
cin>>A[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n Ingrese el valor del elemento: B["<<i+1<<"]["<<j+1<<"]= ";
cin>>B[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n A["<<i+1<<"]["<<j+1<<"]=  ";
cout<<A[i][j] ;
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n B["<<i+1<<"]["<<j+1<<"]=  ";
cout<<B[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
C[i][j] = A[i][j] - B[j][j];
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n C["<<i+1<<"]["<<j+1<<"]=  ";
cout<<C[i][j] ;
}
}
case 3:
{
     cout<<"\n\n";
     cout<<"MATRIS INVERSA";
     cout<<"==============";
     cout<<"\n\n";
     for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n Ingrese el valor del elemento: A["<<i+1<<"]["<<j+1<<"]= ";
cin>>A[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n Ingrese el valor del elemento: B["<<i+1<<"]["<<j+1<<"]= ";
cin>>B[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n A["<<i+1<<"]["<<j+1<<"]=  ";
cout<<A[i][j] ;
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n B["<<i+1<<"]["<<j+1<<"]=  ";
cout<<B[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
C[i][j] = A[i][j] - B[j][j];
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n C["<<j+1<<"]["<<i+1<<"]=  ";
cout<<C[i][j] ;
}  
 }

case 4:
     cout<<setw(50)<<"MATRIS TRANSPUESTA";
     cout<<setw(50)<<"==================";
     cout<<"\n";
          cout<<"\n\n";
     cout<<"MATRIS INVERSA";
     cout<<"\n\n";
     for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n Ingrese el valor del elemento: A["<<i+1<<"]["<<j+1<<"]= ";
cin>>A[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n Ingrese el valor del elemento: B["<<i+1<<"]["<<j+1<<"]= ";
cin>>B[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n A["<<i+1<<"]["<<j+1<<"]=  ";
cout<<A[i][j] ;
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n B["<<i+1<<"]["<<j+1<<"]=  ";
cout<<B[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
C[i][j] = A[i][j] - B[j][j];
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n C["<<j+1<<"]["<<i+1<<"]=  ";
cout<<C[i][j] ;
}
}
getch();
}
    default:
                 cout << setw(50) << "grupo default de instrucciones"<<endl;
                 getch();
    }
 }while (opcion!=0);
getch();
}

             

2 parcial

using namespace std;
#include <iostream>
#include <conio.h>
#include <math.h>
#include <iomanip>
#define N 4
    int opcion,n,i,j,k;
    int G[4][4], H[4][4], K[4][4],Y[4][4];
    int A[4][4], B[4][4], C[4][4];
    int P[5][5],Q[5][5];
int main()
{
do
{
    cout << setw(57) << "************* MENU *************\n" << endl;
    cout << "1) PROBLEMA NUMERO 1" << endl;
    cout << "2) PROBLEMA NUMERO 2" << endl;
    cout << "3) PROBLEMA NUMERO 3" << endl;
    cout << "4) PROBLEMA NUMERO 4" << endl;
    cout << "POR FAVOR  INGRESE UNA OPCION / <0> PARA SALIR: "; cin>> opcion;
    cout << "\n\n";
    switch(opcion)
    {
    case 1:
         {
                 
         cout.setf(ios::fixed);
         cout.precision(3);
         cout << "********************************************************************************\n\n";
         cout << setw(50) << "PROBLEMA NUMERO 1" << endl;
         cout << setw(50) << "=================";
         cout << "\n\n";

cout<<"\n\n INGRESE EL TAMAÑO DE LA MATRIZ: ";cin>>n;

for(i =0; i < n; i++)
for(j =0; j < n;j++)
   {
     cout<<"\n Ingrese el valor del elemento: P["<<i+1<<"]["<<j+1<<"]= ";
     cin>>P[i][j];
   }


// Lectura de la Matriz P[m,n]
for(i =0; i < n; i++)
for(j =0; j < n;j++)
   {
     cout<<"\n P["<<i+1<<"]["<<j+1<<"]=  ";
     cout<<P[i][j];
   }

for(i =0; i < n; i++)
for(j =0; j < n; j++)
   {
       Q[i][j]= P[i][j];
   }

for(i=0; i < n; i++)
for(j =0; j < n; j++)
   {
     cout<<"\n Q["<<i+1<<"]["<<j+1<<"]=  ";
     cout<<Q[i][j];
   }
#define N 4
{
int I;
double max;
double min;
int numeros[N];
int i;
int maximo, minimo;
// INICIALIZO
minimo=1000;
maximo=0;
// LECTURA DE LOS ELEMENTOS VECTOR
for(i=0;i<N;i++)
{      cout<<"\n Ingrese el numero "<<i+1<<" = ";  cin>>(numeros[i]);}
// PROCESO calcula el MAXIMO Y EL MINIMO
for(i=0;i<N;i++)
         {
if(numeros[i]<minimo)
minimo=numeros[i];
if(numeros[i]>maximo)
maximo=numeros[i];
  }
cout<<"\n";
cout<<"EL MAXIMO  ES : "<<maximo;
cout<<"\n";
cout<<"EL MINIMO  ES : "<<minimo;
cout<<"\n";
//calculo  maximo
cout<<"ingresar =";cin>>I;
for(max=0;max<0;max++)
{   max=maximo;   }
cout<<" maximo es=\n"<<max<<",";
cout<< "FIN \n";

cout<<"ingresar =";cin>>I;
for(min=0;min<0;min++)
{     min=minimo;   }
cout <<"\n";
cout<<" minimo es=\n"<<min<<",";
cout<< "FIN \n";
getch();
}


getch();

                     
         }
    break;
    case 2:
         {
                  int i,j,k,n;
                  float x;
                  n=4;
                  int E[4][4],T[4][4],U[4][4];
                  cout.setf(ios::fixed);
                  cout.precision(2);
                  cout << "********************************************************************************\n\n";
                  cout << setw(50) << "PROBLEMA NUMERO 2" << endl;
                  cout << setw(50) << "=================";
                  cout << "\n\n";
                  cout << "Escribir un programa que llene una matriz de 4 por 4 de valores aleatorios" << endl;
    for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
    {
    cout<<"\n Ingrese el valor del elemento: A["<<i+1<<"]["<<j+1<<"]= ";
    cin>>E[i][j] ;
    }


// Lectura de la Matriz A[m,n]
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n A["<<i+1<<"]["<<j+1<<"]=  ";
     cout<<E[i][j] ;
   }

// calcular el producto de los elementos de las matrices
//A  en C
       cout<<"\n SUMA DE COLUMNAS\n\n";

         for (i = 0; i < n; i++)
         for (j = 0; j < n; j++)
         {
         C[i][j] = E[i][j];
       }
// VER EL RESULTADO DEL PRODUCTO DE SUS ELEMENTOS

// Lectura de la Matriz C[m,n]
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n C["<<i+1<<"]= ";
     cout<<C[i][j] ;
   }
   cout<<"\n SUMA DE COLUMNAS\n\n";
 
         for (i = 0; i < n; i++)
         for (j = 0; j < n; j++)
         {
         U[i][j] = E[i][j];
       }
// VER EL RESULTADO DEL PRODUCTO DE SUS ELEMENTOS

// Lectura de la Matriz C[m,n]
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n U["<<j+1<<"]= ";
     cout<<U[i][j] ;
   }


system("pause");
return 0;
}


    break;
    case 3:
         {
                  cout.setf(ios::fixed);
                  cout.precision(3);
                  cout << "********************************************************************************\n\n";
                  cout << setw(50) << "PROBLEMA NUMERO 3" << endl;
                  cout << setw(50) << "=================";
                  cout << "\n\n";
                 
                 
                 
                 
       
         }
    case 4:
         {
                 int i,j,k,n,x;
                  n=3;
                  int G[3][3], H[3][3], Y[3][3], K[3][3];
                  cout.setf(ios::fixed);
                  cout.precision(3);
                  cout << "********************************************************************************\n\n";
                  cout << setw(50) << "PROBLEMA NUMERO 4" << endl;
                  cout << setw(50) << "=================";
                  cout << "\n\n";
                 
                  cout <<"SUMA DE LA MATRIZ" << endl;
                  cout <<"RESTA DE LA MATRIZ" << endl;
                  cout <<"INVERSA DE LA MATRIZ" << endl;
                  cout << "TRANSPUESTA DE LA MATRIZ" << endl;
                  cout << "POR FAVOR  INGRESE UNA OPCION / <0> PARA SALIR: "; cin>> opcion;
                  cout << "\n\n";
                  switch(opcion)
                  {
                   case 1:
                        {
cout<<setw(50)<<"CALCULO DE LA RESTA DE LA MATRIZ"<<endl;                    
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n Ingrese el valor del elemento: A["<<i+1<<"]["<<j+1<<"]= ";
     cin>>A[i][j] ;
   }

//MATRIZ B
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n Ingrese el valor del elemento: B["<<i+1<<"]["<<j+1<<"]= ";
     cin>>B[i][j] ;
   }


// Lectura de la Matriz A[m,n]
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n A["<<i+1<<"]["<<j+1<<"]=  ";
     cout<<A[i][j] ;
   }

// Lectura de la Matriz B[m,n]
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n B["<<i+1<<"]["<<j+1<<"]=  ";
     cout<<B[i][j] ;
   }

// calcular el producto de los elementos de las matrices
//A y B en C

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
C[i][j] = A[i][j] + B[j][j];
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n C["<<i+1<<"]["<<j+1<<"]=  ";
cout<<C[i][j] ;
}
getch();
}      
 case 2:
     
{        
cout<<setw(50)<<"CALCULO DE LA RESTA DE LA MATRIZ"<<endl;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n Ingrese el valor del elemento: A["<<i+1<<"]["<<j+1<<"]= ";
cin>>A[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n Ingrese el valor del elemento: B["<<i+1<<"]["<<j+1<<"]= ";
cin>>B[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n A["<<i+1<<"]["<<j+1<<"]=  ";
cout<<A[i][j] ;
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n B["<<i+1<<"]["<<j+1<<"]=  ";
cout<<B[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
C[i][j] = A[i][j] - B[j][j];
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n C["<<i+1<<"]["<<j+1<<"]=  ";
cout<<C[i][j] ;
}
}
case 3:
{
     cout<<"\n\n";
     cout<<"MATRIS INVERSA";
     cout<<"==============";
     cout<<"\n\n";
     for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n Ingrese el valor del elemento: A["<<i+1<<"]["<<j+1<<"]= ";
cin>>A[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n Ingrese el valor del elemento: B["<<i+1<<"]["<<j+1<<"]= ";
cin>>B[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n A["<<i+1<<"]["<<j+1<<"]=  ";
cout<<A[i][j] ;
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n B["<<i+1<<"]["<<j+1<<"]=  ";
cout<<B[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
C[i][j] = A[i][j] - B[j][j];
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n C["<<j+1<<"]["<<i+1<<"]=  ";
cout<<C[i][j] ;
}  
 }

case 4:
     cout<<setw(50)<<"MATRIS TRANSPUESTA";
     cout<<setw(50)<<"==================";
     cout<<"\n";
          cout<<"\n\n";
     cout<<"MATRIS INVERSA";
     cout<<"\n\n";
     for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n Ingrese el valor del elemento: A["<<i+1<<"]["<<j+1<<"]= ";
cin>>A[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n Ingrese el valor del elemento: B["<<i+1<<"]["<<j+1<<"]= ";
cin>>B[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n A["<<i+1<<"]["<<j+1<<"]=  ";
cout<<A[i][j] ;
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n B["<<i+1<<"]["<<j+1<<"]=  ";
cout<<B[i][j] ;
}

for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
C[i][j] = A[i][j] - B[j][j];
}
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout<<"\n C["<<j+1<<"]["<<i+1<<"]=  ";
cout<<C[i][j] ;
}
}
getch();
}
    default:
                 cout << setw(50) << "grupo default de instrucciones"<<endl;
                 getch();
    }
 }while (opcion!=0);
getch();
}