#include <bits/stdc++.h>
using namespace std;
double x,y;
double r,theta;
void calc(int i);
int main(int argc, const char * argv[]) {
int code;
while(1)
{
cout<<"(0为退出程序,1为平面直角化极坐标,2为极坐标化平面直角)"<<endl;
cout<<"请输入值:";
cin>>code;
if(!code) break;
calc(code);
}
return 0;
}
void calc(int i)
{
if(i==1)
{
cout<<"请输入平面直角坐标系的x轴与y轴:";
cin>>x>>y;
r=sqrt(pow(x,2)+pow(y,2));
theta=atan(y/x);
cout<<"r="<<r<<" ";
cout<<"theta="<<theta<<endl;
}else if(i==2)
{
cout<<"请输入极坐标系的r与theta:";
cin>>r>>theta;
x=r*cos(theta);
y=r*sin(theta);
cout<<"x="<<x<<" ";
cout<<"y="<<y<<endl;
}
}