#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979
struct j{
double len;
double jd;
};
struct z{
double x;
double y;
};
struct z jtoz(struct j pj);
int main(void)
{
double hd;
struct j pj = {
sqrt(2.0),//根号2,45度的边长是1
45.0,
};
struct z zj;
zj=jtoz(pj);
printf("x=%lf y=%lf\n",zj.x,zj.y);
}
struct z jtoz(struct j pj)
{
struct z zj;
double hd;
hd=pj.jd*PI/180.0;
zj.x = pj.len * cos(hd);
zj.y = pj.len * sin(hd);
return zj;
}