有 #include"stdio.h"
class complex
{
double real,image;
public:
complex(double r,double i)
{
real=r;image=i;
}
complex(){}
void input(double r,double i)
{
real=r;image=i;
}
complex div(complex &t)
{
complex temp;
temp.real=(real*t.real+image*t.image)/(t.real*t.real+t.image*t.image);
temp.image=(image*t.real-t.image*real)/t.real*t.real+t.image*t.image);
return temp;
}
void output()
{
if(image>0)printf("%lf+%lfi\n",real,image);
else if(image<0)printf("%lf%lfi\n",real,image);
else printf("%lf\n",real);
}
};
complex p1,p2,p3;
void input()
{
double real,image;
scanf("%lf%lf",&real,&image);
p1.input(real,image);
scanf("%lf%lf",&real,&image);
p2.input(real,image);
}
void Quotient()
{
p3=p1.div(p2);
}
void output()
{
p3.output();
}
void main()
{
input();
Quotient();
output();
} 复数求商
http://zhidao.baidu.com/question/323681475.html?oldq=1