#include <stdio.h>
#include <math.h>
struct complex
{
double real;
double imaginary;
};
struct magphase
{
double magnitude;
double phase;
};
void F_magphase(struct complex *plex, struct magphase *mag);
void main()
{
struct complex p;
struct magphase q;
printf("구하고자 하는 복소수의 a+bj의 a 와 b를 적으시오 : ");
scanf("%lf %lf", &p.real, &p.imaginary);
F_magphase(&p, &q);
printf("%lf %lf ---> %lf %lf", p.real, p.imaginary, q.magnitude, q.phase);
}
void F_magphase(struct complex *plex, struct magphase *mag)
{
mag->magnitude = sqrt((plex->real)(plex->real) + (plex->imaginary)(plex->imaginary));
mag->phase = atan2(plex->imaginary / plex->real);
}
복소수의 위상이랑 절대값을 구하는 프로그램인데 뭐가 잘못된건지...ㅠㅠ
뭐가 안되는질 말해줘야징
응, 쉬운건데 처음 하느라 당황했나봐. sqrt((plex->real)(plex->real) + (plex->imaginary)(plex->imaginary)) 에서 * 빠졌고, 그 다음 줄에 atan2(plex->imaginary / plex->real) 는 atan2(plex->imaginary , plex->real) 가 아닐까?