#include <stdio.h>
struct cmplx {
double a;
double b;
};
struct cmplx cprod(struct cmplx za, struct cmplx zb) {
struct cmplx tmp;
tmp.a = za.a*zb.a-za.b*zb.b;
tmp.b = za.a*zb.b+za.b*zb.a;
return tmp;
}
int main(int argc, char const* argv[])
{
struct cmplx a = {1,2};
struct cmplx b = {2,4};
struct cmplx c = cprod(a,b);
printf("%f+%fi * %f+%fi = %f+%fi\n", a.a,a.b,
b.a,b.b,
c.a,c.b);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgpzdHJ1Y3QgY21wbHggewoJZG91YmxlIGE7Cglkb3VibGUgYjsKfTsKCnN0cnVjdCBjbXBseCBjcHJvZChzdHJ1Y3QgY21wbHggemEsIHN0cnVjdCBjbXBseCB6YikgewoJc3RydWN0IGNtcGx4IHRtcDsKCXRtcC5hID0gemEuYSp6Yi5hLXphLmIqemIuYjsKCXRtcC5iID0gemEuYSp6Yi5iK3phLmIqemIuYTsKCXJldHVybiB0bXA7Cn0KCmludCBtYWluKGludCBhcmdjLCBjaGFyIGNvbnN0KiBhcmd2W10pCnsKCXN0cnVjdCBjbXBseCBhID0gezEsMn07CglzdHJ1Y3QgY21wbHggYiA9IHsyLDR9OwoJc3RydWN0IGNtcGx4IGMgPSBjcHJvZChhLGIpOwoJcHJpbnRmKCIlZislZmkgKiAlZislZmkgPSAlZislZmlcbiIsCgkJCWEuYSxhLmIsCgkJCWIuYSxiLmIsCgkJCWMuYSxjLmIpOwoJcmV0dXJuIDA7Cn0K