top of page

CLASE 5

 #include <iostream>
  #include <math.h>
  using namespace std;
  int main()
  {
      int opcion;
      cout<<"***************************** \n";
      cout<<"menu de complejos \n";
      cout<<"1)Conversion R -> P \n";
      cout<<"2)Conversion P -> R \n";
      cout<<"3)Suma -> R \n"; 
      cout<<"4)Divide -> p \n"; 
      cout<<"5)Suma -> p \n";
      cout<<"6)Divide -> r \n";
      cin>>opcion;
      switch (opcion)
      { 
                   case 1:
                   
                        { //DECLARACION (conversion r - p)
                        cout<<"(conversion R -> P)\n" ;
                           double x1,y1,x2,y2,r;
                         double  phi1,pi=3.141592,r1,r2,RAD1,RAD2;
                          cout<<"(radio1) "; cin>>r1; 
                          cout<<"(radio2) " ; cin>>r2; 
                          cout<<"(PHI1)  " ; cin>>phi1; 
                          if (phi1>30){
                                        RAD1=(2*pi*phi1)/360;
                          RAD2=(2*pi*phi1)/360;
                          x1=r1*cos(RAD1);
                          y1=r1*sin(RAD1);
                          x2=r2*cos(RAD2);
                          y2=r2*sin(RAD2);
                          //rectangular
                          cout<<"z1= "<<(x1+x2)<<"+j "<<(y1+y2)<<endl;
                          //polar
                          r=sqrt(pow((x1+x2),2)+pow((y1+y2),2));
                          phi1= atan((y1+y2)/(x1+x2));
                          cout<<"radio "<<r<< " angulo "<<phi1<<endl;
                          cout<<"opcion 2";}
                          else
                           cout<<"VALOR DEL ANGULO MUY BAJO";  
                        };break;
                   case 2:
                        {//DECLARACION 
                         cout<<"(conversion P -> R)\n" ;
                         double X1,Y1,X2,Y2,r;
                         double  phi,phi2,pi=3.141592,R1,R2,RA1,RA2;
                          cout<<"(radio1)"; cin>>R1; 
                          cout<<"(radio2)" ; cin>>R2; 
                          cout<<"(angulo)  " ; cin>>phi2; 
                          if (R1<9){
                                      RA1 = (2*pi*phi2)/360;
                          RA2 = (2*pi*phi2)/360;
                          X1 = R1*cos(RA1);
                          Y1 = R1*sin(RA1);
                          X2 = R2*cos(RA2);
                          Y2 = R2*sin(RA2);
                          //polar
                          r=sqrt(pow((X1+X2),2)+pow((Y1+Y2),2));
                          phi= atan((Y1+Y2)/(X1+X2));
                          cout<<"radio: "<<r<<" angulo: "<<phi<<endl;
                          //rectangular
                          cout<<"z1= "<<(X1+X2)<<" +j "<<(Y1+Y2)<<endl;
                          cout<<"opcion 1";}else
                         cout<<"VALOR DE R1 MUY ALTOS " ;
                        };break;
                   case 3:
                        { //declaracion (suma - r)
                        cout<<"(SUMA -> R)\n" ;
                          int r1,r2;
                          double phi1,RAD1,RAD2,pi=3.141592,x1,x2,y1,y2;
                         
                          //asignacion
                         cout<<"(radio1)"; cin>>r1;
                         cout<<"(radio2)"; cin>>r2;
                         cout<<"(phi1)"; cin>>phi1;
                          
      
                          //convertir
                          RAD1=(2*pi*phi1)/360;
                          RAD2=(2*pi*phi1)/360;
                          x1=r1*cos(RAD1);
                          y1=r1*sin(RAD1);
                          x2=r2*cos(RAD2);
                          y2=r2*sin(RAD2);
                          //rectangular
                          cout<<"z1= "<<(x1+x2)<<" +j "<<(y1+y2)<<endl;
                          cout<< "opcion 3";     
                        };break;
                   case 4:
                        { // declaracion (multiplicacion - p)
                        cout<<"(Divide -> P)\n" ;
                          int x1,y1,x2,y2;
                          double r1,r2,phi1,phi2,x,y,r,phi;
                          
                        cout<<"(x1) "; cin>>x1;
                        cout<<"(y1 "; cin>>y1;
                        cout<<"(x2 "; cin>>x2;
                        cout<<"(y2 "; cin>>y2;
                        if (y2>10){
                                     r1=sqrt(x1*x1+y1*y1);
                        r2=sqrt(pow(x2,2)+pow(y2,2));
                        phi1=atan(y1/x1); 
                        phi2=atan(y2/x2); 
                           //dividir polar
                        cout<<"radio= "<<(r1/r2)<<" angulo= "<<(phi1-phi2)<<endl;
                           //rectangular
                        x=(r1/r2)*cos(phi1-phi2);
                        y=(r1/r2)*sin(phi1-phi2);
                        cout<<"z1= "<<x<<" +j "<<y<<endl;
                        cout<< "opcion 4";}else
                          cout<< "MENOR";  
                        };break;
                    case 5:
                        { //declaracion (suma - r)
                        cout<<"(SUMA -> p)\n" ;
                          int r1,r2,x1,x2,y1,y2;
                          double RAD1,RAD2,pi=3.141592,phi1,phi2;
                         
                          //asignacion
                        cout<<"(x1 "; cin>>x1;
                        cout<<"(y1 "; cin>>y1;
                        cout<<"(x2 "; cin>>x2;
                        cout<<"(y2 "; cin>>y2;
                          //convertir
                        r1=sqrt(x1*x1+y1*y1);
                        r2=sqrt(pow(x2,2)+pow(y2,2));
                        phi1=atan(y1/x1); 
                        phi2=atan(y2/x2);
                          //rectangular
                          cout<<"radio= "<<(r1+r2) <<"angulo= "<<(phi1+phi2)<<endl;
                          cout<< "opcion 5 \n";     
                        };break;
                    case 6:
                        {cout<<"(DIVIDIR -> R)\n" ;
                           int r1,r2;
                           double x1,y1,x2,y2,pi=3.141592,phi1,phi2,RAD1,RAD2,x,y;
                           cout<<"(radio1)"; cin>>r1;
                           cout<<"(radio2)"; cin>>r2;
                           cout<<"(phi1)"; cin>>phi1;
                           if (x1<10)
                            RAD1=(2*pi*phi1)/360;
                            RAD2=(2*pi*phi1)/360;
                            x1=r1*cos(RAD1);
                            y1=r1*sin(RAD1);
                            x2=r2*cos(RAD2);
                            y2=r2*sin(RAD2); 
                            
                            r1=sqrt(x1*x1+y1*y1);
                        r2=sqrt(pow(x2,2)+pow(y2,2));
                        phi1=atan(y1/x1); 
                        phi2=atan(y2/x2);
                         
                         cout<<"radio= "<<(r1/r2)<<" angulo= "<<(phi1-phi2)<<endl;
                           //rectangular
                        x=(r1/r2)*cos(phi1-phi2);
                        y=(r1/r2)*sin(phi1-phi2);
                        
                        cout<<"z1= "<<x<<" +j "<<y<<endl;
                        cout<< "opcion 4";
                        };break;
              cout<<"opcion fuera de rango";
    }//fin switch
    system("pause");
    return 0;
   }//fin programa 

bottom of page