#include <stdio.h>
typedef struct
{double Real; double Im;} Complex;
Complex ComplexMultiply(Complex z1, Complex z2)
{
Complex z;
z.Real = z1.Real * z2.Real - z1.Im * z2.Im;
z.Im = z1.Real * z2.Im + z1.Im * z2.Real;
return z;
}
int main()
{
Complex z1, z2, z;
z1.Real = 0.25; z1.Im = -3.1412;
z2.Real = 0.98; z2.Im = 1.655;
z = ComplexMultiply(z1, z2);
printf("The product of z1 * z2 = %lf + %lf I.\n", z.Real, z.Im);
return 0;
}
|