Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- typedef struct
- {
- double real;
- double imm;
- } Complex;
- Complex product(Complex c1, Complex c2)
- {
- Complex result;
- result.real = c1.real * c2.real - c1.imm * c2.imm;
- result.imm = c1.real * c2.imm + c1.imm * c2.real;
- return result;
- }
- void print_complex(Complex c)
- {
- printf("%d + %di", c.real, c.imm);
- }
- int main()
- {
- Complex c1, c2, c3;
- c1.real = 4;
- c1.imm = 5; // 4 + 5i
- // ...
- // c2 = 8 + 6i
- // c3 = 0
- Complex nums[] = {c1, c2, c3};
- Complex prod;
- prod.real = 1;
- prod.imm = 0;
- for (int i = 0; i < 3; i++)
- prod = product(prod, nums[i]);
- print_complex(prod); // dovrebbe essere 0 + 0i
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement