Complex numbers in C ++

5

I'm new to C ++ and would like to know how to use complex numbers without being as follows:

double real[2]={2,5};
double imaginario[2]{7,9};  
cout << "Soma: " << real[0]+real[1] << "+" << imaginario[0]+imaginario[1] << "i";

Is there a library for this?

    
asked by anonymous 10.12.2015 / 23:53

1 answer

7

There is sim:

#include <iostream>
#include <complex>
using namespace std;

int main(){

    complex<double> a={2,7}, b={5,9};
    cout << "Soma: " << a+b;

}
    
10.12.2015 / 23:54