#include<iostream>
#include<cmath>
using namespace std;
struct rext //直角坐标系
{
double x;
double y;
};
struct polar //极坐标系
{
double distance;
double angle;
};
void rect_to_polar(const rext*pxy, polar *pda)
{
pda->distance = sqrt(pxy->x * pxy->x + pxy->y * pxy->y);
pda->angle = atan2(pxy->y, pxy->x);
}
void show_polar(const polar * pda)
{
const double Red_to_deg = 57.29577951;
cout << "distance = " << pda->distance << endl;
cout << "angle = " << pda->angle*Red_to_deg << endl;
}
int main()
{
rext rplace;
polar pplace;
cout << "Enter the x and y :";
while (cin >> rplace.x >> rplace.y)
{
rect_to_polar( &rplace, &pplace);
show_polar(&pplace);
cin.get();
}
cin.get();
return 0;
}