c语言复数 运用模板
#include <stdio.h>
#include <complex.h>
int main(void) {
// complex double k = 1.0+2.0*_Complex_I; //可能原因是编译器还在默认沿用c89标准所以无法编译通过(编译器 Dev-C++ 5.11、Code::Blocks 17.12)
__complex__ double a = 1.0+2.0*_Complex_I; //有效格式
double __complex__ b = 1.0+2.0*_Complex_I;
_Complex double c = 1.0+2.0*_Complex_I;
double _Complex d = 1.0+2.0*_Complex_I;
printf("d=%f+%fi", creal(c), cimag(c)); //creal 复数的实部, cimag 复数的虚部
return 0;
}