📄 shj_11.cpp
字号:
#include <iostream.h>
class Complicate
{
public:
Complicate(double shibu,double xubu){x=shibu;y=xubu;}
void Print();
friend void Plus(Complicate &a,Complicate &b);
friend void Substract(Complicate &a,Complicate &b);
friend void Multiply(Complicate &a,Complicate &b);
friend void Division(Complicate &a,Complicate &b);
private:
double x,y;
};
void Complicate::Print()
{
cout<<"("<<x<<")"<<"+"<<"i"<<"("<<y<<")"<<endl;
}
void Plus(Complicate &a,Complicate &b)
{
double newx=a.x+b.x;
double newy=a.y+b.y;
cout<<"Plus="<<"("<<newx<<")"<<"+"<<"i"<<"("<<newy<<")"<<endl;
}
void Substract(Complicate &a,Complicate &b)
{
double newx=a.x-b.x;
double newy=a.y-b.y;
cout<<"Substract="<<"("<<newx<<")"<<"+"<<"i"<<"("<<newy<<")"<<endl;
}
void Multiply(Complicate &a,Complicate &b)
{
double newx=a.x*b.x-a.y*b.y;
double newy=a.x*b.y+b.x*a.y;
cout<<"Multiply="<<"("<<newx<<")"<<"+"<<"i"<<"("<<newy<<")"<<endl;
}
void Division(Complicate &a,Complicate &b)
{
double newx=(a.x*b.x+a.y*b.y)/(b.x*b.x+b.y*b.y);
double newy=(b.x*a.y-a.x*b.y)/(b.x*b.x+b.y*b.y);
cout<<"Division="<<"("<<newx<<")"<<"+"<<"i"<<"("<<newy<<")"<<endl;
}
void main()
{
Complicate c1(5.0,-5.0),c2(-3.0,4.0);
c1.Print();
c2.Print();
Plus(c1,c2);
Substract(c1,c2);
Multiply(c1,c2);
Division(c1,c2);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -