#include <stdio.h>
typedef struct {
double Re; /** 実部 **/
double Im; /** 虚部 **/
} Complex;
int input(Complex *z)
{
scanf("%lf %lf", &z
->Re
, &z
->Im
); return 0;
}
Complex wa(Complex z1, Complex z2)
{
Complex z;
z.Re = z1.Re + z2.Re;
z.Im = z1.Im + z2.Im;
return z;
}
Complex seki(Complex z1, Complex z2)
{
Complex z;
z.Re = (z1.Re * z2.Re) - (z1.Im * z2.Im);
z.Im = (z2.Re * z1.Im) + (z1.Re * z2.Im);
return z;
}
int main()
{
Complex z1, z2, z;
input(&z1);
input(&z2);
z = wa(z1, z2);
printf("z1+z2 Re=%f Im=%f\n", z.
Re, z.
Im); z = seki(z1, z2);
printf("z1+z2 Re=%f Im=%f\n", z.
Re, z.
Im); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp0eXBlZGVmIHN0cnVjdCB7Cglkb3VibGUgUmU7IC8qKiDlrp/pg6ggKiovCglkb3VibGUgSW07IC8qKiDomZrpg6ggKiovCn0gQ29tcGxleDsKCmludCBpbnB1dChDb21wbGV4ICp6KQp7CglwcmludGYoIlJlIEltPSIpOwoJc2NhbmYoIiVsZiAlbGYiLCAmei0+UmUsICZ6LT5JbSk7CglyZXR1cm4gMDsKfQoKQ29tcGxleCB3YShDb21wbGV4IHoxLCBDb21wbGV4IHoyKQp7CglDb21wbGV4CXo7CgoJei5SZSA9IHoxLlJlICsgejIuUmU7Cgl6LkltID0gejEuSW0gKyB6Mi5JbTsKCXJldHVybiB6Owp9CgpDb21wbGV4IHNla2koQ29tcGxleCB6MSwgQ29tcGxleCB6MikKewoJQ29tcGxleAl6OwoKCXouUmUgPSAoejEuUmUgKiB6Mi5SZSkgLSAoejEuSW0gKiB6Mi5JbSk7Cgl6LkltID0gKHoyLlJlICogejEuSW0pICsgKHoxLlJlICogejIuSW0pOwoJcmV0dXJuIHo7Cn0KCmludCBtYWluKCkKewoJQ29tcGxleAl6MSwgejIsIHo7CgoJcHJpbnRmKCJ6MVxuIik7CglpbnB1dCgmejEpOwoJcHJpbnRmKCJ6MlxuIik7CglpbnB1dCgmejIpOwoJeiA9IHdhKHoxLCB6Mik7CglwcmludGYoInoxK3oyIFJlPSVmIEltPSVmXG4iLCB6LlJlLCB6LkltKTsKCXogPSBzZWtpKHoxLCB6Mik7CglwcmludGYoInoxK3oyIFJlPSVmIEltPSVmXG4iLCB6LlJlLCB6LkltKTsKCXJldHVybiAwOwp9Cg==