martes, 10 de septiembre de 2013

matrices


matrices

vectores


vectorers

Matrices

#include<stdlib.h>
#include<iostream>
using namespace std;

int i,j,k,n;
int A[5][5], B[5][5], C[5][5],D[5][5];

int main()
{
cout << "\n\n Ingrese el tamaño de la matriz: "; cin>>n;
//INICIALIZACION
/*for (i = 0; i < n; i++)
for (j = 0; i < n; j++)
   {
     A[i][j] = 0;
     B[i][j] = 0;
     C[i][j] = 0;
     D[i][j]=0;
   }
// ASIGNACION DE DATOS A LA MATRIZ */
//MATRIZ A

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] ;
   }
//MATRIZ c
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n Ingrese el valor del elemento: C["<<i+1<<"]["<<j+1<<"]= ";
     cin>>C[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] ;
   }
// Lectura de la Matriz C[m,n]
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
   {
     cout<<"\n C["<<i+1<<"]["<<j+1<<"]=  ";
     cout<<C[i][j] ;
   }
// calcular el producto de los elementos de las matrices
//A , B y C en D.

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

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


system("pause");
return 0;
}


/*for (k = 0; k < n; k++) {
D[i][j] += A[i][k] + B[k][j] -C[i][j]
}
}
}*/

Vectores

//Que lea 10 números por teclado, los almacene en un array y muestre la suma, resta, multiplicación y división de todos.

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
            int x,tabla[10];
            int sum,res,mul,div;
         
            for (x=0;x<10;x++)
            {
        printf("Introduzca numero\n");
        scanf("%d",&tabla[x]);
    }
         
            sum=tabla[0];
    res=tabla[0];
    mul=tabla[0];
    div=tabla[0];
         
            for (x=1;x<10;x++)
            {
        sum=sum+tabla[x];
        res=res-tabla[x];
        mul=mul*tabla[x];
        div=div/tabla[x];
    }
         
            printf("Suma: %d\n",sum);
            printf("Resta: %d\n",res);
            printf("Multiplicacion: %d\n",mul);
            printf("Division: %d\n",div);
         
    system("PAUSE");    
    return 0;
}

martes, 9 de julio de 2013

Presentacion en Prezi

http://prezi.com/fj7aglsikizj/edit/#122_20166879

Tercer Trabajo

#include <iostream>
      int x;
      float a,b,c,d;

float espacio(float,float);
float velocidad(float,float);
float tiempo(float,float);
float fuerza(float,float);
float energia_cinetica(float,float);
float energia_potencial(float,float);
float trabajo(float,float);
float potencia(float,float);
float presion(float,float);
float velocidad_propagacion(float,float);

using namespace std;

int main()
{
    int op;
    float l;

    do
    {
    cout << endl << "MENU DE FORMULAS" << endl << endl;
cout << "1. ESPACIO" << endl;
cout << "2. VELOCIDAD" << endl;
cout << "3. TIEMPO" << endl;
cout << "4. FUERZA" << endl;
cout << "5. ENERGIA POTENCIAL" << endl;
cout << "6. ENERGIA CINETICs" << endl;
cout << "7. TRABAJO" << endl;
cout << "8. POTENCIA" << endl;
cout << "9. PRESION" << endl;
cout << "10. VELOCIDAD DE PROPAGACION" << endl;
cout << "0. Finalizar" << endl << endl;
cout << "Introduzca la opcion elegida: ";
cin >> op;

if ( op != 0 )
{
do
{

} while ( l<0 );

switch (op)
{
case 1:
{
         cout << "CALCULO DEL ESPACIO \n\n";
         cout << "INGRESE LA VELOCIDAD : "; cin>>a;
         cout << "INGRESE EL TIEMPO : "; cin>>b;
         d = espacio(a,b);
         cout <<"El ESPACIO ES : "<<d<<"\n\n";
    break;
       }
break;
case 2:
{
            cout << "CALCULO DE LA VELOCIDAD \n\n ";
            cout << "INGRESE EL ESPACIO : "; cin>>a;
            cout << "INGRESE EL TIEMPO : "; cin>>b;
            if (b != 0 )
              {
                d= velocidad(a,b);
                cout <<"LA VELOCIDAD ES : "<<d<<"\n\n";
              }
            else
              cout<<"INDETERMINADO";
      break;
         }
case 3:
{
            cout << "CALCULO DEL TIEMPO \n\n ";
            cout << "INGRESE EL ESPACIO : "; cin>>a;
            cout << "INGRESE LA VELOCIDAD : "; cin>>b;
            if (b != 0 )
              {
                d= tiempo(a,b);
                cout <<"EL TIEMPO ES : "<<d<<"\n\n";
              }
            else
              cout<<"INDETERMINADO";
      break;
         }
case 4:
                 {
         cout << "CALCULO DE LA FUERZA \n\n ";
         cout << "INGRESE LA MASA : "; cin>>a;
         cout << "INGRESE LA ACELERACION : "; cin>>b;
         d=fuerza(a,b);
         cout <<"LA FUERZA ES : "<<d<<"\n\n";
    break;
       }
            case 5:
                 {
         cout << "CALCULO DE LA ENERGIA CINETICA \n\n ";
         cout << "INGRESE LA MASA : "; cin>>a;
         cout << "INGRESE LA VELOCIDAD : "; cin>>b;
         d= energia_cinetica(a,b);
         cout <<"LA ENERGIA CINETICA ES : "<<d<<"\n\n";
    break;
       }
            case 6:
                 {
         cout << "CALCULO DE ENERGIA POTENCIAL \n\n ";
         cout << "INGRESE LA MASA : "; cin>>a;
         cout << "INGRESE LA ALTURA : "; cin>>b;
         d= energia_potencial(a,b);
         cout <<"LA ENERGIA POTENCIAL ES : "<<d<<"\n\n";
    break;
       }
             case 7:
                  {
         cout << "CALCULO DEL TRABAJO\n\n ";
         cout << "INGRESE LA FUERZA : "; cin>>a;
         cout << "INGRESE LA DISTANCIA : "; cin>>b;
         d= trabajo(a,b);
         cout <<"EL TRABAJO ES : "<<d<<"\n\n";
    break;
       }
             case 8:
                   {
         cout << "CALCULO DE LA POTENCIA\n\n ";
         cout << "INGRESE EL TRABAJO : "; cin>>a;
         cout << "INGRESE EL TIEMPO : "; cin>>b;
         d= potencia(a,b);
         cout <<"LA POTENCIA ES : "<<d<<"\n\n";
    break;
       }
             case 9:
                    {
         cout << "CALCULO DE LA PRESION\n\n ";
         cout << "INGRESE LA FUERZA : "; cin>>a;
         cout << "INGRESE EL AREA : "; cin>>b;
         d= presion(a,b);
         cout <<"LA PRESION ES : "<<d<<"\n\n";
    break;
       }
             case 10:
                  {
         cout << "CALCULO VELOCIDAD DE PROPAGACION\n\n ";
         cout << "INGRESE LA FRECUENCIAR : "; cin>>a;
         cout << "INGRESE LA LONGITUD : "; cin>>b;
          d=velocidad_propagacion(a,b);
          cout <<"LA VELOCIDAD DE PROPAGACION = "<<d<<"\n\n";

    break;
       }    
defaul:
cout << endl << "Opcion no valida" << endl;
break;
}

}
    // FIN DEL PRIMER BUCLE
    } while ( op != 0 );

    cout << endl << "Gracias por utilizar el programa" << endl;


    return 0;

}

float espacio(float a,float b)
{
return a*b;
}

float velocidad(float a,float b)
{
return a/b;
}

float tiempo(float a,float b)
{
return a/b;
}

float fuerza(float a,float b)
{
return a*b;
}

float energia_cinetica(float a,float b)
{
return (a*(b*b))/2;;
}

float energia_potencial(float a,float b)
{
return (a*b)*9.8;
}
float trabajo(float a,float b)
{
 return a*b;
}
float potencia(float a,float b)
{
 return a/b;
}
float presion(float a,float b)
{
 return a/b;
}
float velocidad_propagacion(float a,float b)
{
 return a*b;
}

viernes, 7 de junio de 2013

Segundo trabajo de LP


#include <iostream>
#include <math.h>
using namespace std;

// VARIABLES PUBLICAS
int opcion,n,i,d,v,b;
double t;
int main ()
{
  // TOMA D DECISION MUILTIPLE
  // INICIO DEL BUBLE DO WHILE
  do
  {
     cout<<"---------------------";
     cout<<"MENU PRINCIPAL \n \n";
     cout<<"1) CALCULO DEL CAMPO ELECTRICO \n";
     cout<<"2) CALCULO DE LA ENERGIA POTENCIAL GRAVITATORIA \n";
     cout<<"3) CALCULO DE LA FUERZA DE INTENSIDAD \n";  
     cout<<" INGRESE UNA OPCION /<0> PARA SALIR \n\n";     cin>>opcion;
 
 
     switch (opcion)
      {
case 1:
           {

           double r;
           int final;
           cout<<"-----------------------------------------\n";
           cout << "CALCULO DEL CAMPO ELECTRICO \n\n" << ", ";
           cout << "INGRESE LA CARGA GENERADORA: "; cin>>final;
           cout << "INGRESE LA DISTANCIA: "; cin>>d;
           for (n=1; n<=final; n++)
             {
               //PROCESO DE CALCULO
               r = (9000*1000000*n)/d*d;    
               cout << r << ", ";
              }
             cout <<"\n"<< r << ", \n ";;
             cout << "FIN!\n";
            }
           break;
         
case 2:
           {    
            int final;  
            cout<<"group of statements 2 \n";
           // CALCULO DE LOS NUMEROS IMPARES
           cout << "\n\n";
           cout << "-----------------------------------------------------------------\n";
           cout << "USO DEL COMANDO WHILE CALCULO DE LA ENERGIA POTENCIAL GRAVITATORIA \n\n";
           cout << "Ingrese LA MASA > ";cin >> final;
           cout << "INGRESE LA ALTURA: "; cin>>b;
            i=1;
            while (i<=final)
              {
               cout << i*b*10 << ", \n ";
               ++i;
              }
            cout << "FIN\n";
           }
            break;
case 3:
           {
            int final;  
            double r;
           // CALCULO DE LOS PUNTOS F(X) DE UNA PARABOLA
           cout << "\n\n";
           cout << "-----------------------------------------------------------------\n";
           cout << "USO DEL COMANDO WHILE --- CALCULO DE LA FUERZA DE INTENSIDAD \n\n";
           cout << "Ingrese la primera carga = ";cin >> b;
           cout << "INGRESE la segunda carga: "; cin>>v;
           cout << "INGRESE la distancia: "; cin>> final;
            i=1;
            while (i<=final)
              {
                  r = (90000*100000*v*b)/(i*i);
               cout << "F( "<< i <<" )"<< " = "<< r << " \n ";
               ++i;
              }
              //cout <<i*i<<" \n ";
            cout << "FIN\n";
           }
            break;

             
        default:
             cout<<"grupo default de instrucciones \n";
      }
     
     // FIN DEL BUBLE WHILE
    } while (opcion!=0);
// FINAL DEL PROGRAMA

  return 0;
}