如何用c中的复数参数进行计算?

如何用c中的复数参数进行计算?,c,C,我在复杂论证的程度上努力转换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

我在复杂论证的程度上努力转换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));
}
#包含/*标准输入输出库*/
#include/*复数标准库*/
常数双PI=3.141592653589793238;
int main()
{
双复数z1=1.0+3.0*I;
双复变元=carg(z1);
printf(“Z1=%.2f Rad=%.2f Degree\n的参数”,参数,参数*(180/PI));
}

由于您使用的是标准库(正如pmg已经指出的),请参考函数原型的规范。以下是一份:

/*实数从笛卡尔形式到极坐标形式的转换*/
#包括
#包括
int main(){
双复数z=-4.4+3.3*I;
双x=creal(z);
双y=cimag(z);
双半径=驾驶室(z);
双参数=carg(z);
printf(“笛卡尔(x,y):(%4.1f,%4.1f)\n”,x,y);
printf(“极轴(r,θ):(%4.1f,%4.1f)\n”),半径,参数;
返回0;
}

双复变元=carg(z1)==>
双参数=carg(z1)。。。并打开编译器警告并注意它们。
 /* 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;
 }