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

PROGRAMMING:Operation of complex number

Luz5年前 (2021-05-10)题库375
Use the four real numbers to construct two complex numbers (according to the order of real part and imaginary part), and determine whether two integer complex numbers or two real complex numbers are constructed according to whether the decimal part of the first real number is zero. Then output in five lines: complex 1, complex 2, complex 1 + complex 2, complex / complex 2, complex 1 compared with complex 2.
The operation rules of complex arithmetic are omitted here. The rule of plural comparison is: compare the real part first, and compare the imaginary part only when the real part is the same. The comparison result is expressed by one of {1 | 0 | - 1} (corresponding to big | and so on | respectively).
###Input format:
Enter four real numbers separated by commas in a row, represented by a, B, C, D, to form two complex numbers, C1 = a + bi, C2 = C + di. If the integer part of the first data a is the same as the whole real number (equivalent to zero after the decimal point), then all complex numbers are considered in the set of integers (int), including operations. Otherwise, the domain of all complex numbers is a real number.
In a word, four real numbers determine two complex numbers (real part and imaginary part), and the decimal part of the first real number determines the domain of complex number. The results are different with different domain.
###Output format:
As mentioned above, enter four real numbers, but the presence or absence of the decimal part of the first number determines whether the domain of the two constructed complex numbers' C1, C2 'is an integer (int) or a real number (double).
The output of the five elements are: the first complex number, the second complex number, the sum of the two complex numbers, the quotient of the two complex numbers, the size comparison of the two complex numbers. Make sure that the second complex number you enter is not zero.
On the output format of complex numbers: output in a pair of [], should meet the following output habits: all zero is only one zero output; When one is zero, only the non-zero part is output. When the imaginary part is negative, such as: 3-4i, do not output: 3 + - 4I. Don't output the decimal part of an integer. When the decimal part of a real number is not zero, keep 3 decimal places. When the decimal part of a real number is zero, don't output the decimal part (output as an integer).
###Input sample 1:
```in
28.000,-45.789,-28.02468,1.1357
```
###Output sample 1:
```out
[28-45i]
[-28+1i]
[-44i]
[-1+1i]
one
```
###Input sample 2:
```in
23.001,-89.0,-23.001,0
```
###Output sample 2:
```out
[23.001-89i]
[-23.001]
[-89i]
[-1+3.869i]
one
```






answer:If there is no answer, please comment