#include #include struct complex{ double re; double im; }; double moduo(struct complex c){ return sqrt(c.re*c.re+c.im*c.im); } struct complex konjugovano(struct complex c){ struct complex cc; cc.re=c.re; cc.im=-c.im; return cc; } struct complex zbir(struct complex u, struct complex v){ struct complex w; w.re=u.re+v.re; w.im=u.im+v.im; return w; } struct complex proizvod(struct complex u, struct complex v){ struct complex w; w.re=u.re*v.re-u.im*v.im; w.im=u.re*v.im+u.im*v.re; return w; } struct complex ucitaj(){ struct complex c; printf("Unesite realan deo: "); scanf("%lf", &c.re); printf("Unesite imaginaran deo: "); scanf("%lf", &c.im); return c; } void pisi(struct complex c){ if(c.im>0) printf("%lf+i*%lf\n", c.re, c.im); else if(c.im<0) printf("%lf-i*%lf\n", c.re, fabs(c.im)); else printf("%lf\n", c.re); } int main(){ struct complex u, v; struct complex z, p, w; /* ucitavamo kompleksne brojeve */ u=ucitaj(); v=ucitaj(); /* moduo kompleksnog broja */ printf("Moduo broja u je: %lf\n", moduo(u)); /* konjugovano kompleksni broj */ printf("Konjugovano kompleksni broj broja v je: "); w=konjugovano(v); pisi(w); /* zbir kompleksinih brojeva */ z=zbir(u,v); printf("Zbir kompleksnih brojeva je: "); pisi(z); /* proizvod kompleksinih brojeva */ p=proizvod(u,v); printf("Proizvod kompleksnih brojeva je: "); pisi(p); return 0; }