fork download
  1. #include <stdio.h>
  2.  
  3. struct cmplx {
  4. double a;
  5. double b;
  6. };
  7.  
  8. struct cmplx cprod(struct cmplx za, struct cmplx zb) {
  9. struct cmplx tmp;
  10. tmp.a = za.a*zb.a-za.b*zb.b;
  11. tmp.b = za.a*zb.b+za.b*zb.a;
  12. return tmp;
  13. }
  14.  
  15. int main(int argc, char const* argv[])
  16. {
  17. struct cmplx a = {1,2};
  18. struct cmplx b = {2,4};
  19. struct cmplx c = cprod(a,b);
  20. printf("%f+%fi * %f+%fi = %f+%fi\n",
  21. a.a,a.b,
  22. b.a,b.b,
  23. c.a,c.b);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.02s 1720KB
stdin
Standard input is empty
stdout
1.000000+2.000000i * 2.000000+4.000000i = -6.000000+8.000000i