请问这个求复数的加减乘除的程序哪错了?
#include<stdio.h>typedef struct complex{
double r;
double i;
}COMPLEX;
COMPLEX *fun1(COMPLEX ,COMPLEX );
COMPLEX *fun2(COMPLEX ,COMPLEX);
COMPLEX *fun3(COMPLEX ,COMPLEX );
COMPLEX *fun4(COMPLEX ,COMPLEX );
int main()
{
COMPLEX a,b,c,d,f,e;
scanf("%d %d %d %d",&a.r,&a.i,&b.r,&b.i);
c=*fun1(a,b);
d=*fun2(a,b);
e=*fun3(a,b);
f=*fun4(a,b);
printf("(%+.2lf+%+.2lfi)+(%+.2lf+%+.2lfi)=(%+.2lf+%+.2lfi)",a.r,a.i,b.r,b.i,c.r,c.i);
printf("(%+.2lf+%+.2lfi)-(%+.2lf+%+.2lfi)=(%+.2lf+%+.2lfi)",a.r,a.i,b.r,b.i,d.r,d.i);
printf("(%+.2lf+%+.2lfi)+(%+.2lf+%+.2lfi)=(%+.2lf+%+.2lfi)",a.r,a.i,b.r,b.i,e.r,e.i);
printf("(%+.2lf+%+.2lfi)+(%+.2lf+%+.2lfi)=(%+.2lf+%+.2lfi)",a.r,a.i,b.r,b.i,f.r,f.i);
return 0;
}
COMPLEX *fun1(COMPLEX a,COMPLEX b )
{
COMPLEX *S;
S->r=a.r+b.r;
S->r=a.i+b.i;
return S;
}
COMPLEX * fun2(COMPLEX a,COMPLEX b )
{
COMPLEX *S;
S->r=a.r-b.r;
S->i=a.i-b.i;
return S;
}
COMPLEX * fun3(COMPLEX a,COMPLEX b )
{
COMPLEX *S;
S->r=a.r*b.r-b.i*a.i;
S->i=a.i*b.r+a.r*b.i;
return S;
}
COMPLEX * fun4(COMPLEX a,COMPLEX b )
{
COMPLEX *S;
S->r=(a.r*b.r+b.i+b.i)/(b.r*b.r+b.i*b.i);
S->i=(a.i+b.r-a.r*b.i)/(b.r*b.r+b.i*b.i);
return S;
}