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
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution