[ create a new paste ] login | about

Link: http://codepad.org/9fR7pqTg    [ raw code | output | fork ]

C, pasted on Dec 7:
#include <stdio.h>

struct c {
  double re;
  double im;
};

struct c mul(struct c a, struct c b)
{
  struct c r;
  r.re = a.re * b.re - a.im * b.im;
  r.im = a.re * b.im + a.im * b.re;
  return r;
}

int main()
{
  struct c x, y, z;
  printf("1: ");
  scanf("%lf %lf", &x.re, &x.im);
  printf("2: ");
  scanf("%lf %lf", &y.re, &y.im);
  z = mul(x, y);
  printf("%lf +  %lfj\n", z.re, z.im);
  return 0;
}
/* end */


Output:
1
1: 2: 0.000000 +  0.000000j


Create a new paste based on this one


Comments: