PROGRAMMING:+, -, *, / operator overload
The main functions of the program are as follows:
1. Realize the addition, subtraction, multiplication and division of two complex numbers (C1 and C2)
2. To realize the addition, subtraction, multiplication and division of complex number C1 and integer num
3. Realize the addition, subtraction, multiplication and division of integer num and complex C1
###Input format:
C1 real part C1 imaginary part
C2 real part C2 imaginary part
Integer num
The specific format is shown in the example
###Output format:
C1 + C2 results
C1-C2 results
C1 * C2 results
C1 / C2 results
C1 + num result
C1 num results
C1 * num result
C1 / num result
Num + C1 result
Num-c1 results
Num * C1 result
Num / C1 results
See the output sample for the specific format
###Input example:
Here is a set of inputs. For example:
```in
1 2
3 4
five
```
###Output example:
The corresponding output is given here. For example:
```out
c1+c2=(4.00,6.00i)
c1-c2=(-2.00,-2.00i)
c1*c2=(-5.00,10.00i)
c1/c2=(0.44,0.08i)
c1+num=(6.00,2.00i)
c1-num=(-4.00,2.00i)
c1*num=(5.00,2.00i)
c1/num=(0.20,2.00i)
num+c1=(6.00,2.00i)
num-c1=(4.00,2.00i)
num*c1=(5.00,2.00i)
num/c1=(5.00,2.00i)
```
answer:If there is no answer, please comment
(1) Declare a complex class with overloaded operators "+", "-", "*", "/", so that it can be used for complex addition, subtraction, multiplication and division. Operator overloaded functions are the member functions of complex class. Program the sum, difference, product and quotient of two complex numbers. be careful:
In sum, difference, product and quotient operations, the two operations involved can be complex objects, or one of them can be an integer in any order. For example:
c1+c2,c1-c1,c1*c2,c1/c2,c1+i,c1-i,c1*i,c1/i,i+c1,i-c1,i*c1,i/c1
complex number and complex number operation rules:
addition rule
Let Z1 = a + bi, Z2 = C + Di be any two complex numbers,
Then the sum of them is (a + bi) + (c + DI) = (a + C) + (B + D) I.
Subtraction rule
Let Z1 = a + bi, Z2 = C + Di be any two complex numbers,
Then the difference is (a + bi) - (c + DI) = (A-C) + (B-D) I.
product rule
Let Z1 = a + bi, Z2 = C + di (a, B, C, D ∈ R) be any two complex numbers, then their product is
(a+bi)(c+di)=(ac -bd)+(bc+ad)i。
Division rule
Let a + bi (a, B ∈ R) be divided by C + di (C, D ∈ R), and its quotient is x + Yi (x, y ∈ R),
x=(ac+bd)/(c2+d2)
y=(bc-ad)/(c2+d2)
complex and integer algorithms:
The real part of complex number and integer operation (addition, subtraction, multiplication, Division), the imaginary part unchanged!
The real part and imaginary part of the result are accurate to 2 decimal places!
1. Realize the addition, subtraction, multiplication and division of two complex numbers (C1 and C2)
2. To realize the addition, subtraction, multiplication and division of complex number C1 and integer num
3. Realize the addition, subtraction, multiplication and division of integer num and complex C1
###Input format:
C1 real part C1 imaginary part
C2 real part C2 imaginary part
Integer num
The specific format is shown in the example
###Output format:
C1 + C2 results
C1-C2 results
C1 * C2 results
C1 / C2 results
C1 + num result
C1 num results
C1 * num result
C1 / num result
Num + C1 result
Num-c1 results
Num * C1 result
Num / C1 results
See the output sample for the specific format
###Input example:
Here is a set of inputs. For example:
```in
1 2
3 4
five
```
###Output example:
The corresponding output is given here. For example:
```out
c1+c2=(4.00,6.00i)
c1-c2=(-2.00,-2.00i)
c1*c2=(-5.00,10.00i)
c1/c2=(0.44,0.08i)
c1+num=(6.00,2.00i)
c1-num=(-4.00,2.00i)
c1*num=(5.00,2.00i)
c1/num=(0.20,2.00i)
num+c1=(6.00,2.00i)
num-c1=(4.00,2.00i)
num*c1=(5.00,2.00i)
num/c1=(5.00,2.00i)
```
answer:If there is no answer, please comment
(1) Declare a complex class with overloaded operators "+", "-", "*", "/", so that it can be used for complex addition, subtraction, multiplication and division. Operator overloaded functions are the member functions of complex class. Program the sum, difference, product and quotient of two complex numbers. be careful:
In sum, difference, product and quotient operations, the two operations involved can be complex objects, or one of them can be an integer in any order. For example:
c1+c2,c1-c1,c1*c2,c1/c2,c1+i,c1-i,c1*i,c1/i,i+c1,i-c1,i*c1,i/c1
complex number and complex number operation rules:
addition rule
Let Z1 = a + bi, Z2 = C + Di be any two complex numbers,
Then the sum of them is (a + bi) + (c + DI) = (a + C) + (B + D) I.
Subtraction rule
Let Z1 = a + bi, Z2 = C + Di be any two complex numbers,
Then the difference is (a + bi) - (c + DI) = (A-C) + (B-D) I.
product rule
Let Z1 = a + bi, Z2 = C + di (a, B, C, D ∈ R) be any two complex numbers, then their product is
(a+bi)(c+di)=(ac -bd)+(bc+ad)i。
Division rule
Let a + bi (a, B ∈ R) be divided by C + di (C, D ∈ R), and its quotient is x + Yi (x, y ∈ R),
x=(ac+bd)/(c2+d2)
y=(bc-ad)/(c2+d2)
complex and integer algorithms:
The real part of complex number and integer operation (addition, subtraction, multiplication, Division), the imaginary part unchanged!
The real part and imaginary part of the result are accurate to 2 decimal places!