怎么解啊!!!!!
#include<iostream.h>class complex
{
float x;
float y;
public:
complex()
{
x=0;
y=0;
}
complex(float vx,float vy)
{x=vx;
y=vy;
}
void print();
friend complex operator +(complex a,complex b);
friend complex operator -(complex a,complex b);
friend complex operator *(complex a,complex b);
friend complex operator /(complex a,complex b);
};
//void complex::print()
//{
// cout<<x;
// if(y>0) cout<<"+";
// if(y!=0)cout<<y<<"i\n";
//}
void complex::print()
{
if(x==0&&y==0)
cout<<"the complex is"<<0<<endl;
else
{
if(y>0)
if(x)
cout<<"the complex is"<<x<<"+"<<"i"<<endl;
else cout<<"the complex is"<<y<<"*i"<<endl;
if(y<0)
{if(x)
cout<<"the complex is"<<x<<y<<"*i"<<endl;
else cout<<"the complex is"<<y<<"*i"<<endl;
}
if(y==0)
cout<<"x"<<endl;
}
complex operator+(complex a,complex b)
z {complex temp;
temp.x=a.x+b.x;
temp.y=a.y+b.y;
return temp;
}
complex operator-(complex a,complex b)
{complex temp;
temp.x=a.x-b.x;
temp.y=a.y-b.y;
return temp;
}
complex operator*(complex a,complex b)
{complex temp;
temp.x=a.x*b.x-a.y*b.y;
temp.y=a.y*b.y+a.x*b.x;
return temp;
}
complex operator/(complex a,complex b)
{complex temp;
float tt;
tt=1/(b.x*b.x+a.y*b.y);
temp.x=(a.x*b.x+a.y*b.y)*tt;
temp.y=(b.x*a.y-a.x*b.y)*tt;
return temp;
}
}
main()
{
cin>>x1>>y1>>;
cin>>x2>>y2>>;
complex a1(float x1,float y1);
complex a2(float x2,float y2),a3;
//complex a1(1,1),a2(2,2),a3;
a3=a1+a2;
a3.print();
a3=a2-a1;
a3.print();
a3=a1*a3;
a3.print();
a3=a1/a2;
a3.print();
return 1;
}