-->
当前位置:首页 > 题库

PROGRAMMING:Four operations of complex number

Luz5年前 (2021-05-10)题库424
This problem requires programming to calculate the sum, difference, product and quotient of two complex numbers.
###Input format:
Input the real part and imaginary part of two complex numbers C1 ='a1 + b1i 'and C2 ='a2 + b2i' in a row according to the format of 'A1 B1 A2 B2'. C2 is not zero.
###Output format:
Output the sum, difference, product and quotient of two complex numbers in 4 lines according to the format sequence of '(a1 + b1i) operator (A2 + b2i) = result', and the number is accurate to 1 decimal place. If the real or imaginary part of the result is 0, it is not output. If the result is 0, output 0.0.
###Input sample 1:
```in
2 3.08 -2.04 5.06
```
###Output sample 1:
```out
(2.0+3.1i) + (-2.0+5.1i) = 8.1i
(2.0+3.1i) - (-2.0+5.1i) = 4.0-2.0i
(2.0+3.1i) * (-2.0+5.1i) = -19.7+3.8i
(2.0+3.1i) / (-2.0+5.1i) = 0.4-0.6i
```
###Input example 2:
```
1 1 -1 -1.01
```
###Output example 2:
```
(1.0+1.0i) + (-1.0-1.0i) = 0.0
(1.0+1.0i) - (-1.0-1.0i) = 2.0+2.0i
(1.0+1.0i) * (-1.0-1.0i) = -2.0i
(1.0+1.0i) / (-1.0-1.0i) = -1.0
```






answer:If there is no answer, please comment