日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > 第八周項目-1.3

第八周項目-1.3

來源:程序員人生   發布時間:2015-05-27 08:22:56 閱讀次數:2444次
#include<iostream>
using namespace std;
class Complex
{
public:
Complex(){ real = 0; imag = 0; }
Complex(double r, double i){ real = r; imag = i; }
Complex operator+(const Complex &c2);
Complex operator-(const Complex &c2);
Complex operator*(const Complex &c2);
Complex operator/(const Complex &c2);
friend Complex operator+(const double &c1,const Complex &c2);
friend  Complex operator-(const double &c1,const Complex &c2);
friend Complex operator*(const double &c1,const Complex &c2);
friend Complex operator/(const double &c1,const Complex &c2);
friend Complex operator+(const Complex &c1,const double &c2);
friend  Complex operator-(const Complex &c1,const double &c2);
friend Complex operator*(const Complex &c1,const double &c2);
friend Complex operator/(const Complex &c1,const double &c2);
void display();
private:
double real;
double imag;
};
//下面定義成員函數
Complex Complex::operator+(const Complex &c2)
{
return Complex(real + c2.real, imag + c2.imag);
}
Complex Complex::operator-(const Complex &c2)
{
return Complex(real - c2.real, imag - c2.imag);
}
Complex Complex::operator*(const Complex &c2)
{
return Complex(real*c2.real - imag*c2.imag, real*c2.imag + imag*c2.real);
}
Complex Complex::operator/(const Complex &c2)//(ac+bd)/(c^2+d^2)+〔(bc-ad)/(c^2+d^2)〕i
{
return Complex((real*c2.real + imag*c2.imag) / (c2.real*c2.real + c2.imag*c2.imag), (imag*c2.real - real*c2.imag) / (c2.real*c2.real + c2.imag*c2.imag));
}
Complex operator+(const double &c1, const Complex &c2)
{
return Complex(c1 + c2.real, c2.imag);
}
Complex operator-(const double &c1, const Complex &c2)
{
return Complex(c1 - c2.real, c2.imag);
}
Complex operator*(const double &c1, const Complex &c2)
{
return Complex(c1 * c2.real, c2.imag);
}
Complex operator/(const double &c1, const Complex &c2)
{
return Complex(c1 / c2.real, c2.imag);
}
Complex operator+(const Complex &c1, const double &c2)
{
return Complex(c1.real + c2, c1.imag);
}
Complex operator-(const Complex &c1, const double &c2)
{
return Complex(c1.real - c2, c1.imag);
}
Complex operator*(const Complex &c1, const double &c2)
{
return Complex(c1.real * c2, c1.imag);
}
Complex operator/(const Complex &c1, const double &c2)
{
return Complex(c1.real / c2, c1.imag);
}
void Complex::display()
{
if (imag == 0)
cout << real << endl;
else if (imag < 0)
cout << real << " - " << -imag << "i" << endl;
else
cout << real << " + " << imag << "i" << endl;
}
//下面定義用于測試的main()函數
int main()
{
Complex c1(3, 4), c2(5, ⑴0), c3;
cout << "c1=";
c1.display();
cout << "c2=";
c2.display();
c3 = c1 + c2;
cout << "c1+c2=";
c3.display();
c3 = c1 - c2;
cout << "c1-c2=";
c3.display();
c3 = c1*c2;
cout << "c1*c2=";
c3.display();
c3 = c1 / c2;
cout << "c1/c2=";
c3.display();
c3 = c1 + 3;
cout << "c1 + 3=";
c3.display();
c3 = ⑸ + c2;
cout << "⑸ + c2=";
c3.display();//-----------------------  +
c3 = c1 - 3;
cout << "c1 - 3=";
c3.display();
c3 = ⑸ - c2;
cout << "⑸ - c2=";
c3.display();//----------------------  -
c3 = c1 * 3;
cout << "c1 * 3=";
c3.display();
c3 = ⑸ * c2;
cout << "⑸ * c2=";
c3.display();//----------------------  *
c3 = c1 / 3;
cout << "c1 / 3=";
c3.display();
c3 = ⑸ / c2;
cout << "⑸ / c2=";
c3.display();//---------------------  /
while (1){}
return 0;
}
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 亚洲一区二区三区综合 | 精品国产欧美一区二区三区成人 | 一级黄色片69 | 亚洲午夜视频 | 韩国福利一区 | 91在线精品一区二区 | 精品国产一区探花在线观看 | 一区二区91 | 99久久精品一区二区成人 | 欧美精品一区二区三区视频 | 国产精品成人一区二区网站软件 | 欧美韩国日本一区二区三区 | 亚洲国产一区视频 | 日韩精品无码一区二区三区 | 小毛片 | 欧洲成人午夜免费大片 | 精品国产一区二区在线 | 日韩精品一区在线 | 国产免费无遮挡 | 午夜成人在线视频 | 久久亚洲春色中文字幕久久久 | av高清| 国产日韩一区二区三区 | 开操网 | 99久国产 | 亚洲香蕉av | a爱视频 | 黄色一级大片在线免费看产 | 欧美日免费 | 黄色在线观看视频网站 | 国产福利在线观看 | 亚洲精品乱码久久久久久写真 | 国产一区二区在线播放 | 国产成人深夜视频51 | 欧美区一| 国产精品久久久久久久久久久免费看 | 色综合天天综合网国产成人网 | 高清性爱视频 | 亚洲成人精品一区二区三区 | 国产精品国产三级国产在线观看 | 午夜国产|