include iostream include string include math define PI 14159 using nam

 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
42
43
44
45
46
47
48
#include <iostream>
#include <string>
#include <math.h>
#define PI 3.14159
using namespace std;
class complex
{
public:
double x;
double y;
double modul()
{
return pow(x*x+y*y,0.5);
}
double argument()
{
return atan2(y,x)*180/PI;
}
void show_complex()
{
if (y>=0)
cout<<x<<"+"<<y<<"i"<<endl;
else
cout<<x<<y<<"i"<<endl;
}
};
int main()
{
complex chislo;
chislo.x=3.5;
chislo.y=-1.432;
chislo.show_complex();
chislo.y=1.432;
chislo.show_complex();
chislo.modul();
cout<<"Modul' chisla="<<chislo.modul();
chislo.argument();
cout<<endl<<"Argument chisla="<<chislo.argument()<<endl;
return 0;
}