How to use complex number “i” in C++

后端 未结 6 836
暗喜
暗喜 2021-02-06 08:19

I am coding a simple DFT algorithm now and I want to use the complex number i in complex exponential. I saw somebody use #include and #include&

6条回答
  •  孤独总比滥情好
    2021-02-06 08:52

    I get this question recently as well and find a easy way for future reader:

    Just use library like the following

    #include 
    #include 
    using namespace std ;
    
    int main(int argc, char* argv[])
    {
        const   complex i(0.0,1.0);    
        cout << i << endl ;
    
        return(0) ;
    }
    

提交回复
热议问题