青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

The Fourth Dimension Space

枯葉北風寒,忽然年以殘,念往昔,語默心酸。二十光陰無一物,韶光賤,寐難安; 不畏形影單,道途阻且慢,哪曲折,如渡飛湍。斬浪劈波酬壯志,同把酒,共言歡! -如夢令

Complex Class (Beta 2.0)

#include<iostream>
#include
<cmath>
using namespace std;


//本模板在VS2005下可正常運行
/*//////////////////////////////BEGIN_TEMPLATE_CALSS_COMPLEX_BY_ABILITYTAO////////////////////////////*/
class Complex
{
private:

    
void show();
    
double real;
    
double image;
public:

    Complex()
{real=0;image=0;}
    
~Complex(){}
    Complex(
double a,double b){real=a;image=b;}
    
double Getreal(){return real;}
    
double Getimage(){return image;}
    
double abs(){return sqrt(real*real+image*image);}
    Complex 
operator +(Complex &other);
    Complex 
operator +(const double &other);
    Complex 
operator +(const int &other);

    Complex 
operator -(Complex &other);
    Complex 
operator -(const double &other);
    Complex 
operator -(const int &other);

    Complex 
operator *(Complex &other);
    Complex 
operator *(const double &other);
    Complex 
operator *(const int &other);

    Complex 
operator /(Complex &other);
    Complex 
operator /(const double &other);
    Complex 
operator /(const int &other);

    
void operator +=(Complex &other);
    
void operator +=(const double &other);
    
void operator +=(const int &other);

    
void operator -=(Complex &other);
    
void operator -=(const double &other);
    
void operator -=(const int &other);

    
void operator *=(Complex &other);
    
void operator *=(const double &other);
    
void operator *=(const int &other);

    
void operator /=(Complex &other);
    
void operator /=(const double &other);
    
void operator /=(const int &other);

    Complex 
operator =(Complex &other);
    Complex 
operator =(const double &other);
    Complex 
operator =(const int &other);

    
bool operator ==(Complex &other);
    
bool operator ==(const double &other);
    
bool operator ==(const int &other);

    friend ostream
& operator<<(ostream &os,Complex &other);
    friend istream
& operator>>(istream &is,Complex &other);
}
;


void Complex::show()
{

    
if(real>0&&image<0)
        printf(
"%g%gj",real,image);
    
else if(real>0&&image>0)
        printf(
"%g+%gj",real,image);
    
else if(real<0&&image>0)
        printf(
"%g+%gj",real,image);
    
else if(real<0&&image<0)
        printf(
"%g%gj",real,image);
    
else if(real==0&&image!=0)
        printf(
"%gj",image);
    
else if(real!=0&&image==0)
        printf(
"%g",real);
    
else 
        printf(
"0");
}


Complex Complex::
operator+(Complex &other)
{
    Complex temp;
    temp.real
=real+other.real;
    temp.image
=image+other.image;
    
return temp;
}


Complex Complex::
operator +(const double &other)
{

    Complex temp;
    temp.real
=real+other;
    temp.image
=image;
    
return temp;
}


Complex Complex::
operator +(const int &other)
{
    Complex temp;
    temp.real
=real+(double)other;
    temp.image
=image;
    
return temp;
}



Complex Complex::
operator-(Complex &other)
{

    Complex temp;
    temp.real
=real-other.real;
    temp.image
=image-other.image;
    
return temp;
}


Complex Complex::
operator -(const double &other)
{

    Complex temp;
    temp.real
=real-(double)other;
    temp.image
=image;
    
return temp;
}


Complex Complex::
operator -(const int &other)
{

    Complex temp;
    temp.real
=real-(double)other;
    temp.image
=image;
    
return temp;
}

Complex Complex::
operator*(Complex &other)
{
    Complex temp;
    temp.real
=(real*other.real-image*other.image);
    temp.image
=(image*other.real+real*other.image);
    
return temp;


}


Complex Complex::
operator *(const double &other)
{
    Complex temp;
    temp.real
=real*other;
    temp.image
=image*other;
    
return temp;
}


Complex Complex::
operator *(const int &other)
{
    Complex temp;
    temp.real
=real*(double)other;
    temp.image
=image*(double)other;
    
return temp;
}


Complex Complex::
operator/(Complex &other)
{

    Complex temp;
    temp.real
=((real*other.real)+(image*other.image))/(other.real*other.real+other.image*other.image);
    temp.image
=((image*other.real)-(real*other.image))/(other.real*other.real+other.image*other.image);
    
return temp;

}


Complex Complex::
operator /(const double &other)
{
    Complex temp;
    temp.real
=real/other;
    temp.image
=image/other;
    
return temp;

}


Complex Complex::
operator /(const int &other)
{
    Complex temp;
    temp.real
=real/(double)other;
    temp.image
=image/(double)other;
    
return temp;
}





void Complex::operator+=(Complex &other)
{
    
this->real+=other.real;
    
this->image+=other.image;
}


void Complex::operator +=(const double &other)
{

    
this->real+=other;
}


void Complex::operator +=(const int&other)
{
    
this->real+=(double)other;
}






void Complex::operator-=(Complex &other)
{
    
this->real-=other.real;
    
this->image-=other.image;
}


void Complex::operator -=(const double &other)
{

    
this->real-=other;
}


void Complex::operator -=(const int &other)
{
    
this->real-=(double)other;
}




void Complex::operator*=(Complex &other)
{
    
this->real=(real*other.real-image*other.image);
    
this->image=(image*other.real+real*other.image);;
}


void Complex::operator *=(const double &other)
{

    
this->real=real*other;
    
this->image=image*other;
}


void Complex::operator *=(const int &other)
{
    
this->real=real*(double)other;
    
this->image=image*(double)other;
}



void Complex::operator/=(Complex &other)
{
    
this->real=((real*other.real)+(image*other.image))/(other.real*other.real+other.image*other.image);
    
this->image=((image*other.real)-(real*other.image))/(other.real*other.real+other.image*other.image);
}


void Complex::operator /=(const double &other)
{

    
this->real=real/other;
    
this->image=image/other;
}


void Complex::operator /=(const int &other)
{
    
this->real=real/(double)other;
    
this->image=image/(double)other;
}


Complex Complex::
operator= (Complex &other)
{

    
this->real=other.real;
    
this->image=other.image;
    
return *this;

}

Complex Complex::
operator =(const double &other)
{
    
this->real=other;
    
this->image=image;
    
return *this;


}

Complex Complex::
operator =(const int &other)
{
    
this->real=(double)other;
    
this->image=image;
    
return *this;
}



bool Complex::operator ==(Complex &other)
{

    
if(this->real=other.real&&this->image==other.image)
        
return true;
    
else return false;
}

bool Complex::operator ==(const double &other)
{

    
if(this->real==other&&this->image==0)
        
return true;
    
else 
        
return false;
}

bool Complex::operator ==(const int &other)
{
    
if(this->real==(double)other&&this->image==0)
        
return true;
    
else 
        
return false;
}


ostream
& operator<<(ostream &os,Complex &other)
{
    other.show();
    
return cout;
}


istream
& operator>>(istream &is,Complex &other)
{
    
is>>other.real;
    
is>>other.image;
    
return cin;
}

/**//////////////////////////////END_TEMPLATE_CLASS_COMPLEX///////////////////////////////









int main()
{
    Complex test1(
10,6);
    Complex test2(
5,3);
    cout
<<test1*test2<<endl;
    cout
<<test1+test2<<endl;
    cout
<<test1/test2<<endl;
    cout
<<test1-test2<<endl;
    
return 0;
}

posted on 2009-05-29 21:37 abilitytao 閱讀(1263) 評論(5)  編輯 收藏 引用

評論

# re: Complex Class (Beta 2.0) 2009-05-29 23:01 playcpp

STL中不是有complex類么,為什么要自己搞個。歡迎加入QQ群 36071431 討論C++問題。  回復  更多評論   

# re: Complex Class (Beta 2.0)[未登錄] 2009-05-30 02:00 abilitytao

@playcpp
為了練習運算符重載 呵呵 這個理由怎么樣  回復  更多評論   

# re: Complex Class (Beta 2.0) 2009-05-30 15:47 WindyWinter

練運算符重載應該寫高精度計算。  回復  更多評論   

# re: Complex Class (Beta 2.0)[未登錄] 2009-05-30 15:56 abilitytao

@WindyWinter
那個有點麻煩呢 呵呵 你知道高精度浮點類要怎么寫嗎?  回復  更多評論   

# re: Complex Class (Beta 2.0) 2009-06-04 11:26 MC

有些可以內聯調用,需要考慮除零問題,高精度浮點類搜索bcd  回復  更多評論   


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久久精品999| 久久精品2019中文字幕| 欧美激情按摩在线| 日韩网站在线看片你懂的| 日韩一级黄色大片| 国产精品s色| 亚洲永久免费av| 欧美一区二区三区久久精品茉莉花 | 91久久在线视频| 99国产精品久久久久久久| 欧美午夜不卡视频| 欧美一区亚洲一区| 亚洲高清免费在线| 亚洲一区中文| 国语自产精品视频在线看| 久久一区免费| aa日韩免费精品视频一| 久久国产精品久久久| 在线视频成人| 欧美日韩中文字幕在线| 欧美在线观看一区二区| 欧美激情亚洲另类| 亚洲免费人成在线视频观看| 国语自产精品视频在线看| 欧美国产日韩一区二区三区| 亚洲免费视频成人| 亚洲第一精品久久忘忧草社区| 亚洲一区二区伦理| 在线视频国产日韩| 欧美亚一区二区| 久久米奇亚洲| 亚洲四色影视在线观看| 牛夜精品久久久久久久99黑人| 亚洲午夜免费视频| 亚洲国产欧美久久| 国产精品一区在线播放| 欧美黑人一区二区三区| 欧美在线观看视频| 99国内精品久久| 欧美大片va欧美在线播放| 午夜免费日韩视频| 日韩午夜剧场| 亚洲成人直播| 国产视频自拍一区| 欧美日韩综合精品| 欧美成人午夜激情视频| 欧美在线观看视频一区二区三区 | 久久国产加勒比精品无码| 亚洲三级电影在线观看| 国内成人精品一区| 欧美视频一区在线| 欧美精品啪啪| 久久色在线播放| 欧美一级网站| 亚洲一区二区日本| 日韩午夜免费| 亚洲国语精品自产拍在线观看| 久久久91精品国产一区二区精品| 亚洲一区二区三区成人在线视频精品 | 亚洲精品一区二区三| 狠狠色噜噜狠狠狠狠色吗综合| 欧美视频一区二| 欧美日本一区二区高清播放视频| 久久亚洲电影| 久久激情久久| 欧美一区二区三区在线免费观看| 亚洲性夜色噜噜噜7777| 在线亚洲高清视频| 99re热这里只有精品视频| 亚洲国内精品| 亚洲国产精品毛片| 最新国产成人av网站网址麻豆| 女同一区二区| 免费成年人欧美视频| 美女亚洲精品| 欧美国产欧美亚洲国产日韩mv天天看完整 | 久久久久久伊人| 久久久久一区| 久久婷婷蜜乳一本欲蜜臀| 久久久久国产精品午夜一区| 久久精品亚洲国产奇米99| 久久精品国亚洲| 久久中文字幕一区| 欧美h视频在线| 亚洲国产美女久久久久 | 亚洲人成啪啪网站| 亚洲国产二区| 99精品国产福利在线观看免费| 一本久道久久久| 亚洲影音一区| 欧美在线视频二区| 久久午夜精品一区二区| 欧美gay视频| 欧美日本一区二区三区| 国产精品户外野外| 国产日韩一区二区三区| 伊人精品成人久久综合软件| 亚洲国内精品| 亚洲视频在线观看三级| 性亚洲最疯狂xxxx高清| 久久琪琪电影院| 欧美电影免费观看| 日韩视频一区二区三区在线播放免费观看| 一区二区三区四区国产精品| 亚洲欧美网站| 另类av一区二区| 欧美日韩亚洲国产精品| 国产欧美日韩在线观看| 在线观看成人网| 一区二区三区精品视频| 久久精品人人| 亚洲精美视频| 性欧美精品高清| 欧美成年人网站| 国产精品亚洲不卡a| 亚洲福利视频在线| 亚洲欧美日韩在线高清直播| 久久色中文字幕| 亚洲蜜桃精久久久久久久| 香蕉av777xxx色综合一区| 嫩草影视亚洲| 国产女同一区二区| 亚洲免费成人| 久久伊人一区二区| 999在线观看精品免费不卡网站| 欧美在线免费播放| 欧美四级在线| 亚洲国产欧美一区| 久久激情一区| 一本色道久久综合亚洲精品不卡 | 可以看av的网站久久看| 日韩香蕉视频| 牛夜精品久久久久久久99黑人| 国产精品永久免费观看| 一本色道综合亚洲| 美脚丝袜一区二区三区在线观看| 亚洲午夜精品一区二区| 欧美成人a视频| 国产在线精品成人一区二区三区 | 亚洲性xxxx| 欧美激情一区二区久久久| 黄色成人片子| 欧美中在线观看| 99这里只有久久精品视频| 免费看亚洲片| 一区在线播放视频| 久久国产精彩视频| 亚洲伊人色欲综合网| 欧美日韩一区二区三区高清| 亚洲精品视频一区| 女主播福利一区| 久久福利毛片| 国产一区二区三区四区在线观看| 亚洲欧美偷拍卡通变态| 99精品免费网| 欧美精品在欧美一区二区少妇| 亚洲国产精品t66y| 美女福利精品视频| 久久久久久久网| 激情久久一区| 另类专区欧美制服同性| 久久成人免费| 狠狠色狠狠色综合人人| 久久久久久久综合狠狠综合| 午夜精品久久久久久久99黑人| 国产精品伦子伦免费视频| 亚洲午夜视频在线| 一区二区不卡在线视频 午夜欧美不卡'| 欧美国产精品劲爆| 99亚洲精品| 日韩视频在线你懂得| 欧美日一区二区在线观看| 一区二区三区精品| 中文国产一区| 国产精品区免费视频| 久久国产99| 久久久久久久成人| 亚洲人成啪啪网站| 亚洲日本无吗高清不卡| 欧美日韩在线影院| 香蕉国产精品偷在线观看不卡| 午夜精品久久久久久久蜜桃app| 国产日韩精品久久| 久久野战av| 欧美成人网在线| 亚洲一级网站| 欧美一区不卡| 亚洲国产精品久久久| 亚洲精品视频一区| 国产精品美腿一区在线看| 久久精品在线播放| 另类专区欧美制服同性| 一区二区三区视频在线| 亚洲综合色在线| 加勒比av一区二区| 91久久精品美女高潮| 国产精品乱码一区二区三区| 久久久亚洲精品一区二区三区 | 亚洲国产精品专区久久| 日韩午夜一区|