我正在努力应对rad的复杂度转换问题。作为争论的结果,我得到了1.25拉德。我想通过计算参数*(180 / PI)将rad转换为度。但是结果是我得到了0.00度,我不知道为什么计算失败。这是我的代码:
#include <stdio.h> /* Standard Library of Input and Output */
#include <complex.h> /* Standard Library of Complex Numbers */
const double PI = 3.141592653589793238;
int main()
{
double complex z1 = 1.0 + 3.0 * I;
double complex argument = carg(z1);
printf("The argument of Z1 = %.2f Rad = %.2f Degree\n", argument, argument*(180/PI));
}
答案 0 :(得分:0)
由于您使用的是标准库(如pmg所指出),因此请参考函数原型的规范。这是example:
/* conversion of a real number from its Cartesian to polar form */
#include <stdio.h>
#include <complex.h>
int main() {
double complex z = -4.4 + 3.3 * I;
double x = creal(z);
double y = cimag(z);
double radius = cabs(z);
double argument = carg(z);
printf("cartesian(x, y): (%4.1f, %4.1f)\n", x, y);
printf("polar(r, theta): (%4.1f, %4.1f)\n", radius, argument);
return 0;
}