complex-numbers

How to work with complex numbers in C?

这一生的挚爱 提交于 2019-11-26 00:25:23
问题 How can I work with complex numbers in C? I see there is a complex.h header file, but it doesn\'t give me much information about how to use it. How to access real and imaginary parts in an efficient way? Is there native functions to get module and phase? 回答1: This code will help you, and it's fairly self-explanatory: #include <stdio.h> /* Standard Library of Input and Output */ #include <complex.h> /* Standard Library of Complex Numbers */ int main() { double complex z1 = 1.0 + 3.0 * I;