98. Add Complex Numbers
Foundation1000 ms256 MBSolved by 0%
A complex number has a real part and an imaginary part.
Read two complex numbers as a b and c d on separate lines, meaning a + bi and
c + di, and print their sum in the form real imaginary, separated by a space.
Add the real parts together and the imaginary parts together.
Constraints - `-1000000 ≤ each part ≤ 1000000`
Input
Two lines, each containing two integers, the real and imaginary parts.
Output
Print two integers on one line, separated by a single space, the real part, then the imaginary part.
Input1 2
3 4
Output4 6
Noteadds two positive complex numbers
Input1 2
-1 -2
Output0 0
Noteadds a number to its negative, cancelling both parts
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.