struct
complex{
float
rmz;
//实部
float
lmz;//虚部
};
//产生一个复数.
complex
getacomplex(float
a,float
b){
complex
node=new
complex();
node.rmz=a;
node.lmz=b;
return
node;}
//两个复数求和
complex
addcomplex(complex
complex1,complex
complex2)
{
complex
node=new
complex();
node.rmz=complex1.rmz+complex2.rmz;
node.lmz=complex1.lmz+complex2.lmz;
return
node;
}
//求两个复数的差
complex
subcomplex(complex
complex1,complex
complex2)
{
complex
node=new
complex();
node.rmz=complex1.rmz-complex2.rmz;
node.lmz=complex1.lmz-complex2.lmz;
return
node;
}
//求两个复数的积
complex
productcomplex(complex
complex1,complex
complex2)
{
complex
node=new
complex();
node.rmz=complex1.rmz*complex2.rmz-complex1.lmz*complex2.lmz;
node.lmz=complex1.lmz*complex2.rmz+complex2.lmz*complex2.rmz;
return
node;
}
//求实部
float
getcomplexrmz(complex
complex1)
{
return
complex1.rmz;
}
//求虚部
float
getcomplexlmz(complex
complex1)
{
return
complex1.lmz;
}