#include<stdio.h>
struct complex
{
double real; //実数部
double imaginary; //虚数部
};
struct complex complex_add(struct complex func_a, struct complex func_b){
struct complex func_c;
func_c.real = func_a.real + func_b.real;
func_c.imaginary = func_a.imaginary + func_b.imaginary;
return func_c;
}
void print_complex(char message[],struct complex a){
printf("%s = %3lf + %3lfi\n",message
,a.
real,a.
imaginary); }
int main(){
struct complex a,b,c;
a.real = 10;
a.imaginary = 5;
b.real = 20;
b.imaginary = 3;
c = complex_add(a,b);
print_complex("a",a);
print_complex("b",b);
print_complex("a + b",c);
return(0);
}
I2luY2x1ZGU8c3RkaW8uaD4Kc3RydWN0IGNvbXBsZXgKewogICAgZG91YmxlIHJlYWw7ICAgIC8v5a6f5pWw6YOoCiAgICBkb3VibGUgaW1hZ2luYXJ5OyAgIC8v6Jma5pWw6YOoCn07CgpzdHJ1Y3QgY29tcGxleCBjb21wbGV4X2FkZChzdHJ1Y3QgY29tcGxleCBmdW5jX2EsIHN0cnVjdCBjb21wbGV4IGZ1bmNfYil7CiAgICBzdHJ1Y3QgY29tcGxleCBmdW5jX2M7CiAgICBmdW5jX2MucmVhbCA9IGZ1bmNfYS5yZWFsICsgZnVuY19iLnJlYWw7CiAgICBmdW5jX2MuaW1hZ2luYXJ5ID0gZnVuY19hLmltYWdpbmFyeSArIGZ1bmNfYi5pbWFnaW5hcnk7CiAgICByZXR1cm4gZnVuY19jOwp9Cgp2b2lkIHByaW50X2NvbXBsZXgoY2hhciBtZXNzYWdlW10sc3RydWN0IGNvbXBsZXggYSl7CiAgICBwcmludGYoIiVzID0gJTNsZiArICUzbGZpXG4iLG1lc3NhZ2UsYS5yZWFsLGEuaW1hZ2luYXJ5KTsKfQoKaW50IG1haW4oKXsKICAgIAogICAgc3RydWN0IGNvbXBsZXggYSxiLGM7CiAgICAKICAgIGEucmVhbCA9IDEwOwogICAgYS5pbWFnaW5hcnkgPSA1OwogICAgYi5yZWFsID0gMjA7CiAgICBiLmltYWdpbmFyeSA9IDM7CiAgICAKICAgIGMgPSBjb21wbGV4X2FkZChhLGIpOwogICAgCiAgICBwcmludF9jb21wbGV4KCJhIixhKTsKICAgIHByaW50X2NvbXBsZXgoImIiLGIpOwogICAgcHJpbnRfY29tcGxleCgiYSArIGIiLGMpOwogICAgCiAgICByZXR1cm4oMCk7Cn0K