Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- typedef struct complex
- {
- float Re, Im;
- }complex;
- complex conjugat(complex x)
- {
- complex temp;
- temp.Re = x.Re;
- temp.Im = (-2)*x.Im;
- return (temp);
- }
- complex add(complex z1, complex z2)
- {
- complex temp;
- temp.Re = z1.Re+z2.Re;
- temp.Im = z1.Im+z2.Im;
- return (temp);
- }
- complex sub(complex z1, complex z2)
- {
- complex temp;
- temp.Re = z1.Re - z2.Re;
- temp.Im = z1.Im - z2.Im;
- return (temp);
- }
- complex prod(complex z1, complex z2)
- {
- complex temp;
- temp.Re = (z1.Re)*(z2.Re)-(z1.Im)*(z2.Im);
- temp.Im = (z1.Re)*(z2.Im)+(z1.Im)*(z2.Re);
- return (temp);
- }
- double mod(complex z)
- {
- double temp = sqrt(pow(z.Re,2)+pow(z.Im,2));
- return (temp);
- }
- void afiseazaNrComplex(complex z)
- {
- printf("%f + %fi",z.Re, z.Im);
- }
- int main()
- {
- complex z1 = {2,5}, z2 = {4,5};
- complex z3 = prod(z1,z2);
- afiseazaNrComplex(z3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement