C complex number and printf

后端 未结 4 1179
無奈伤痛
無奈伤痛 2020-12-01 11:38

How to print ( with printf ) complex number? For example, if I have this code:

#include 
#include 
int main(void)
{
    doubl         


        
4条回答
  •  被撕碎了的回忆
    2020-12-01 12:36

    Using GNU C, this works:

    printf("%f %f\n", complexnum);
    

    Or, if you want a suffix of "i" printed after the imaginary part:

    printf("%f %fi\n", complexnum);
    

提交回复
热议问题