方法一:
#include <stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
struct complex multiply(struct complex x, struct complex y);
struct complex{
int real;
int imag;
};
int main()
{
struct complex a,b,s;
scanf("%d%d%d%d",&a.real,&a.imag,&b.real,&b.imag);
s=multiply(a,b);
printf("(%d+%di)*(%d+%di)=%d+%di\n",a.real,a.imag,b.real,b.imag,s.real,s.imag);
return 0;
}
struct complex multiply(struct complex x, struct complex y)
{
struct complex m;
m.real=x.real*y.real-x.imag*y.imag;
m.imag=x.imag*y.real+x.real*y.imag;
return m;
}
方法二:
#include<stdio.h>
int main()
{
int a,b,c,d,e,f;
scanf("%d %d %d %d",&a,&b,&c,&d);
e = a * c - b * d;
f = a * d + b * c;
printf("(%d+%di)*(%d+%di)=%d+%di\n",a,b,c,d,e,f);
}
本回答被网友采纳