pat上的题,实在解释不了为什么错

#include<stdio.h>
struct complex {
int real;
int imag;
};
struct complex multiply(struct complex x, struct complex y)
{
int real;
int imag;
real = x.real * y.real -x.imag * y.imag;
imag = x.real * y.imag+x.imag * y.real;
};

int main()
{
struct complex product, x, y;
scanf_s("%d%d%d%d", &x.real, &x.imag, &y.real, &y.imag);
product =multiply(x, y);
printf("(%d+%di)*(%d+%di)=%d+%di\n", x.real, x.imag, y.real, y.imag, product.real, product.imag);
return 0;
}

调试发现i前面永远是1,解释不了为什么错,有没有会的把改对的代码发出来

修改如下,供参考:

#include<stdio.h>
struct complex {
      int real;
      int imag;
};

struct complex multiply(struct complex x, struct complex y)
{
      //int real;
      //int imag;
      struct complex tmp;
      tmp.real = x.real * y.real - x.imag * y.imag;
      tmp.imag = x.real * y.imag + x.imag * y.real;
      return tmp;
};

int main()
{
      struct complex product, x, y;
      scanf_s("%d%d%d%d", &x.real, &x.imag, &y.real, &y.imag);
      product = multiply(x, y);
      printf("(%d+%di)*(%d+%di)=%d+%di\n", x.real, x.imag, y.real, y.imag, product.real, product.imag);
      
      return 0;
}

struct complex multiply没有返回。

struct complex multiply(struct complex x, struct complex y)
{
    struct complex t;
    t.real = x.real * y.real -x.imag * y.imag;
    t.imag = x.real * y.imag+x.imag * y.real;
    return t;
};