jueves, 11 de agosto de 2016

PRACTICA 2

SEGUNDA PRACTICA PROGRAMACION


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

const int N=10, p=3, q=4;
int LeerVector(int n);
int MirarVector(int n);
int d, i, j, V[N], M[p][q];
void Problema();
void LeerMatriz();
void MirarMatriz();
void Problema2();

int main()
{
int Opcion;
do
{// inicia el do while
 cout<<"****** MENU ****** \n\n";
 cout<<"1) Leer un Vector\n";    
 cout<<"2) Mirar el Vector  \n";    
 cout<<"3) PROBLEMA \n";   
 cout<<"4) Leer una Matriz\n";    
 cout<<"5) Mirar la Matriz  \n";    
 cout<<"6) PROBLEMA 2\n\n";     
 cout<<"****************** \n\n";    
 cout<<"     Digite <0> para salir \n";
 cout<<"     Ingrese una Opcion: "; cin>> Opcion;
 cout<<endl;

 switch(Opcion)
  {
   case 1:
   {
     cout<<" **** Leer un Vector **** \n";
     LeerVector(N);
   }; break;
   case 2:
   {
    cout<<" *** Mirar el Vector**  \n";        
    MirarVector(N);
   }; break;
   case 3:
   {
    cout<<" PROBLEMA \n";        
    Problema();
   }; break;
    case 4:
   {
     cout<<" **** Leer una Matriz **** \n";
     LeerMatriz();
   }; break;

 case 5:
   {
     cout<<" **** Mirar una Matriz **** \n";
     MirarMatriz();
   }; break;
 case 6:
   {
     cout<<" **** PROBLEMA 2 **** \n";
     Problema2();
   }; break;

  } // FIN DEL CASO
}while(Opcion !=0);

system("pause");
return 0;
}

int LeerVector(int n)
{
 for (i=1; i<= 10; i++)
  V[i]= 45 + i;
}
int MirarVector(int n)
{
 for (i=1; i<= n; i++)
  cout<<V[i]<<endl;
}

void Problema()
{
 int BETA;
 long double P, ALFA;
 for (i=1; i<=10; i++) 
 {
  cout<<i<<endl;
  BETA=(180-V[i])/2;
 cout<<"BETA ES IGUAL: "<<BETA<<endl; 
  ALFA = 90-BETA-30;
 cout<<"ALFA ES IGUAL: "<<ALFA<<endl;
  P=(140*cos(BETA))*2;
 cout<<"LA FUERZA P ES: "<<P<<endl;

 }
}
void LeerMatriz()
{
  d=0;
 for(i=1; i<=p; i++)
  for(j=1; j<=q; j++)
  {
   d = d + 10;
   M[i][j]= 45 + d;
  }
}

void MirarMatriz()
{
 for(i=1; i<=p; i++)
  for(j=1; j<=q; j++)
  {
   cout<<M[i][j]<<endl;
  }

}

void Problema2()
{
 int BETA;
 long double P, ALFA;

for (i=1; i<=p; i++)    
for (j=1; j<=q; j++)    
 {
  cout<<i<<endl;
  BETA=(180-M[i][j])/2;
 cout<<"BETA ES IGUAL: "<<BETA<<endl; 
  ALFA = 90-BETA-30;
 cout<<"ALFA ES IGUAL: "<<ALFA<<endl;
  P=(140*cos(BETA))*2;
 cout<<"LA FUERZA P ES: "<<P<<endl;

 }
}