알고리즘

[복소수] #include <complex>

parkit 2018. 11. 23. 13:46
728x90
반응형

복소수


complex



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <complex>
 
using namespace std;
 
// http://seismic.yonsei.ac.kr/complex.html
 
int main(void)
{
    complex<double> com3(13);
    complex<double> com1(12);
 
    complex<double> c;
 
    c = com3 - com1;
 
    cout << "실수부 = " << c.real() << ", 허수부 = " << c.imag() << '\n';
 
    double a = 0.0, b = 0.0;
 
    scanf("%lf %lf"&a, &b);
 
    complex<double> ab(a, b);
 
    cout << "실수부 = " << ab.real() << ", 허수부 = " << ab.imag() << '\n';
 
    if (ab.imag() != 0)
    {
        // printf("%ld\n", sqrt(pow((double)ab.real(), 2.0) + pow((double)ab.imag(), 2.0)));
 
        cout << sqrt(pow((double)ab.real(), 2.0+ pow((double)ab.imag(), 2.0)) << '\n';
    }
    return 0;
}
cs


728x90
반응형