PROGRAMMING:Real and imaginary parts of complex numbers
A complex number is usually represented by a string in the form of "a + bi". A is the real part of the complex number and B is the imaginary part of the complex number. Now we need to separate the input string, automatically identify the real part and imaginary part of the complex number, and output independently.
For example, for the input complex string "3-4.05i", the output
complex 3-4.05i
the real part is 3
and the imaginary part is -4.05
be careful:
1. A string used to represent a complex number is mathematically written.
2. Each set of test data contains only one string used to represent complex numbers.
3. The input is guaranteed to be legal.
Input example:
-4.567+3.987i
Output example:
complex -4.567+3.987i
the real part is -4.567
and the imaginary part is 3.987
answer:If there is no answer, please comment
For example, for the input complex string "3-4.05i", the output
complex 3-4.05i
the real part is 3
and the imaginary part is -4.05
be careful:
1. A string used to represent a complex number is mathematically written.
2. Each set of test data contains only one string used to represent complex numbers.
3. The input is guaranteed to be legal.
Input example:
-4.567+3.987i
Output example:
complex -4.567+3.987i
the real part is -4.567
and the imaginary part is 3.987
answer:If there is no answer, please comment