top of page
CLASE 10/04/19
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
int opcion;
cout<<"1)convertir de R a P \n";
cout<<"2)convertir de P a R \n";
cout<<"3)suma de R \n";
cout<<"4)divide P \n";
cout<<"5)suma P \n";
cout<<"6)multiplica R\n";
cout<<"ingrese una opcion :"; cin>>opcion;
switch(opcion)
{
{
case 1:
{
cout<<"convertir de R a P\n";
double x1,y1,x2,y2,r;
double phi1,pi=3.1416,r1,r2,RAD1,RAD2;
if (phi1<5)
{
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;
//POLAR
r=sqrt(pow((x1+x2),2)+pow((y1+y2),2));
phi1=atan((y1+y2)/(x1+x2));
cout<<"radio: "<<r<<"angulo:"<<phi1<<endl;
}else
cout<<"fuera de rango";
}break;
case 2:
{
cout<<"convertir de P a R \n";
double x1,y1,x2,y2,r;
double phi,phi1,phi2,pi=3.1416,r1,r2,RAD1,RAD2;
//CONVERTIR
if(r1<10)
{
cout<<"(radio1) "; cin>>r1;
cout<<"(radio2)"; cin>>r2;
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);
//POLAR
r=sqrt(pow((x1+x2),2)+pow((y1+y2),2));
phi1=atan((y1+y2)/(x1+x2));
cout<<"radio: "<<r<<"angulo: "<<phi<<endl;
//RECTANGULAR
cout<<"z1= "<<(x1+x2)<<"+j "<<(y1+y2)<<endl;
}else
cout<<"fuera de rango";
}break;
case 3:
{
cout<<"suma de R \ n";
int r1,r2;
double phi1,pi=3.1416,RAD1,RAD2,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;
}break;
case 4:
{
cout<<"divide P \ n";
int x1,y1,x2,y2;
double phi,phi1,phi2,r,r1,r2,x,y;
if(y2<5)
{
cout<<"(x1)";cin>>x1;
cout<<"(y1)";cin>>y1;
cout<<"(x2)";cin>>x2;
cout<<"(y2)";cin>>y2;
r1=sqrt(x1*x1*y1*y1);
r2=sqrt(pow(x2,2)+pow(y2,2));
phi1=atan(y1/x1);
phi2=atan(y2/x2);
//MULTIPLICAR
cout<<"radio= "<<(r1*r2)<<" angulo= "<<(phi1-phi2)<<endl;
x=(r1*r2)*cos(phi1-phi2);
y=(r1*r2)*sin(phi1-phi2);
//POLAR
r=sqrt(pow((x1+x2),2)+pow((y1+y2),2));
phi1=atan((y1+y2)/(x1+x2));
cout<<"radio: "<<r<<"angulo: "<<phi<<endl;
}else
cout<< "fuera de rango";
}break;
case 5:
{
cout<<"suma P \ n";
int r1,r2;
double x1,x2,y1,y2,phi,phi1,phi2,pi=3.1416,r,RAD1,RAD2;
//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);
//POLAR
r=sqrt(pow((x1+x2),2)+pow((y1+y2),2));
phi1=atan((y1+y2)/(x1+x2));
cout<<"radio: "<<r<<"angulo:"<<phi<<endl;
}break;
case 6:
{
cout<<"multiplica R \ n";
int x1,y1,x2,y2;
double phi1,phi2,r1,r2,x,y;
cout<<"(x1)";cin>>x1;
cout<<"(y1)";cin>>y1;
cout<<"(x2)";cin>>x2;
cout<<"(y2)";cin>>y2;
if(x1<10)
{
r1=sqrt(x1*x1*y1*y1);
r2=sqrt(pow(x2,2)+pow(y2,2));
phi1=atan(y1/x1);
phi2=atan(y2/x2);
//DIVIDIR
cout<<"radio="<<(r1/r2)<<"angulo="<<(phi1-phi2)<<endl;
x=(r1/r2)*cos(phi1-phi2);
y=(r1/r2)*sin(phi1-phi2);
//RECTANGULAR
cout<<"z1= "<<(x1+x2)<<"+j "<<(y1+y2)<<endl;
cout<<"opcion6";
}else
cout<<"fuera de rango";
}break;
}//verdadero del switch
defaul:
cout<<"no es opcion real"<<endl;
} //fin de switch
//retun 0;
}//fin del programa#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
int opcion;
cout<<"1)convertir de R a P \n";
cout<<"2)convertir de P a R \n";
cout<<"3)suma de R \n";
cout<<"4)divide P \n";
cout<<"5)suma P \n";
cout<<"6)multiplica R\n";
cout<<"ingrese una opcion :"; cin>>opcion;
switch(opcion)
{
{
case 1:
{
cout<<"convertir de R a P\n";
double x1,y1,x2,y2,r;
double phi1,pi=3.1416,r1,r2,RAD1,RAD2;
if (phi1<5)
{
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;
//POLAR
r=sqrt(pow((x1+x2),2)+pow((y1+y2),2));
phi1=atan((y1+y2)/(x1+x2));
cout<<"radio: "<<r<<"angulo:"<<phi1<<endl;
}else
cout<<"fuera de rango";
}break;
case 2:
{
cout<<"convertir de P a R \n";
double x1,y1,x2,y2,r;
double phi,phi1,phi2,pi=3.1416,r1,r2,RAD1,RAD2;
//CONVERTIR
if(r1<10)
{
cout<<"(radio1) "; cin>>r1;
cout<<"(radio2)"; cin>>r2;
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);
//POLAR
r=sqrt(pow((x1+x2),2)+pow((y1+y2),2));
phi1=atan((y1+y2)/(x1+x2));
cout<<"radio: "<<r<<"angulo: "<<phi<<endl;
//RECTANGULAR
cout<<"z1= "<<(x1+x2)<<"+j "<<(y1+y2)<<endl;
}else
cout<<"fuera de rango";
}break;
case 3:
{
cout<<"suma de R \ n";
int r1,r2;
double phi1,pi=3.1416,RAD1,RAD2,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;
}break;
case 4:
{
cout<<"divide P \ n";
int x1,y1,x2,y2;
double phi,phi1,phi2,r,r1,r2,x,y;
if(y2<5)
{
cout<<"(x1)";cin>>x1;
cout<<"(y1)";cin>>y1;
cout<<"(x2)";cin>>x2;
cout<<"(y2)";cin>>y2;
r1=sqrt(x1*x1*y1*y1);
r2=sqrt(pow(x2,2)+pow(y2,2));
phi1=atan(y1/x1);
phi2=atan(y2/x2);
//MULTIPLICAR
cout<<"radio= "<<(r1*r2)<<" angulo= "<<(phi1-phi2)<<endl;
x=(r1*r2)*cos(phi1-phi2);
y=(r1*r2)*sin(phi1-phi2);
//POLAR
r=sqrt(pow((x1+x2),2)+pow((y1+y2),2));
phi1=atan((y1+y2)/(x1+x2));
cout<<"radio: "<<r<<"angulo: "<<phi<<endl;
}else
cout<< "fuera de rango";
}break;
case 5:
{
cout<<"suma P \ n";
int r1,r2;
double x1,x2,y1,y2,phi,phi1,phi2,pi=3.1416,r,RAD1,RAD2;
//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);
//POLAR
r=sqrt(pow((x1+x2),2)+pow((y1+y2),2));
phi1=atan((y1+y2)/(x1+x2));
cout<<"radio: "<<r<<"angulo:"<<phi<<endl;
}break;
case 6:
{
cout<<"multiplica R \ n";
int x1,y1,x2,y2;
double phi1,phi2,r1,r2,x,y;
cout<<"(x1)";cin>>x1;
cout<<"(y1)";cin>>y1;
cout<<"(x2)";cin>>x2;
cout<<"(y2)";cin>>y2;
if(x1<10)
{
r1=sqrt(x1*x1*y1*y1);
r2=sqrt(pow(x2,2)+pow(y2,2));
phi1=atan(y1/x1);
phi2=atan(y2/x2);
//DIVIDIR
cout<<"radio="<<(r1/r2)<<"angulo="<<(phi1-phi2)<<endl;
x=(r1/r2)*cos(phi1-phi2);
y=(r1/r2)*sin(phi1-phi2);
//RECTANGULAR
cout<<"z1= "<<(x1+x2)<<"+j "<<(y1+y2)<<endl;
cout<<"opcion6";
}else
cout<<"fuera de rango";
}break;
}//verdadero del switch
defaul:
cout<<"no es opcion real"<<endl;
} //fin de switch
//retun 0;
}//fin del programa
bottom of page