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

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 閱讀(1257) 評論(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>
            亚洲青色在线| 日韩视频三区| 依依成人综合视频| 国产精品av久久久久久麻豆网| 中文日韩在线视频| 亚洲欧美日韩久久精品| 久久久999国产| 日韩一区二区精品| 亚洲人成网站在线观看播放| 黄色精品在线看| 亚洲欧洲精品一区二区三区不卡 | 日韩视频精品| 亚洲高清二区| 日韩一级不卡| 欧美精品免费观看二区| 国产综合网站| 国产欧美日韩综合一区在线观看| 最近看过的日韩成人| 91久久精品国产91久久性色tv| 欧美日韩国产黄| 国产日韩欧美一区| 一本综合精品| 欧美成人免费播放| 亚洲视频每日更新| 亚洲视频网站在线观看| 欧美有码在线观看视频| 欧美激情一区二区三区高清视频 | 亚洲日本乱码在线观看| 免费观看不卡av| 国产日韩欧美一区二区三区在线观看| 亚洲精品欧洲精品| 小处雏高清一区二区三区| 亚洲国产综合在线看不卡| 中文亚洲欧美| 亚洲精品孕妇| 亚洲人成网站精品片在线观看| 久久这里只有| 午夜视黄欧洲亚洲| 免费日韩成人| 一区二区冒白浆视频| 亚洲欧美国产不卡| 国产区日韩欧美| 老司机午夜精品| 欧美色图麻豆| 久热精品在线视频| 欧美二区在线播放| 欧美影院在线播放| 免费观看国产成人| 午夜激情亚洲| 农夫在线精品视频免费观看| 亚洲欧美日韩国产综合在线 | 亚洲一区日韩在线| 欧美日韩免费观看一区=区三区| 亚洲激情影院| 亚洲精美视频| 久久国产精品亚洲va麻豆| 亚洲日本精品国产第一区| 亚洲欧美日韩在线综合| 榴莲视频成人在线观看| 欧美天天在线| 亚洲日本欧美| 在线观看福利一区| 欧美激情精品久久久久| 久久久久久亚洲精品不卡4k岛国| 久久亚裔精品欧美| 久久av在线看| 欧美色综合网| 91久久精品视频| 亚洲第一视频网站| 久久久久久**毛片大全| 久久免费视频网站| 国产在线日韩| 性欧美1819性猛交| 午夜精品福利视频| 国产精品久久久久9999| 亚洲丝袜av一区| 午夜视频在线观看一区二区三区| 欧美性大战久久久久久久蜜臀| 亚洲精品乱码久久久久久蜜桃麻豆| 136国产福利精品导航网址| 久久精品国产第一区二区三区| 欧美在线观看一区二区| 国产一区在线视频| 久热精品视频在线| 亚洲毛片播放| 亚洲欧美激情精品一区二区| 国产欧美一二三区| 性刺激综合网| 欧美成人在线网站| 亚洲欧美国产三级| 亚洲成人在线免费| 夜夜嗨av一区二区三区网页| 亚洲一区二区黄| 亚洲国产cao| 韩国一区二区三区在线观看 | 麻豆精品视频在线| 亚洲欧美色一区| 亚洲午夜精品| 欧美在线3区| 欧美一区二视频在线免费观看| 亚洲天堂av高清| 美女国产一区| 最新亚洲一区| 久久综合中文色婷婷| 欧美一级欧美一级在线播放| 亚洲成色999久久网站| 国产亚洲人成网站在线观看 | 欧美成人精品不卡视频在线观看| 一区二区不卡在线视频 午夜欧美不卡'| 国产亚洲一区二区在线观看 | 一级成人国产| 亚洲精品久久| 日韩一级在线| 亚洲永久精品国产| 亚洲资源av| 亚洲永久在线观看| 亚洲欧美日本国产专区一区| 中日韩男男gay无套| 亚洲一区二区影院| 欧美一区二区高清在线观看| 久久激情综合网| 快she精品国产999| 欧美成人综合| 国产精品免费看久久久香蕉| 国产精品一区在线播放| 国产区亚洲区欧美区| 夜夜夜久久久| 午夜视频久久久| 久久久久国产免费免费| 欧美第一黄网免费网站| 欧美日韩一卡二卡| 国产午夜精品理论片a级探花| 在线日韩中文字幕| 亚洲午夜在线观看| 久久综合久久久久88| 亚洲乱码国产乱码精品精98午夜| 亚洲在线免费| 欧美日韩亚洲一区二区三区四区| 国内久久视频| 先锋影音久久久| 亚洲激情偷拍| 可以看av的网站久久看| 欧美网站在线观看| 亚洲区在线播放| 免费不卡视频| 香蕉久久一区二区不卡无毒影院 | 国产精品99久久久久久久久| 久久裸体艺术| 久久精品国产一区二区三区免费看 | 久久久久久亚洲精品中文字幕| 亚洲黄页视频免费观看| 欧美在线视频在线播放完整版免费观看| 欧美日韩亚洲一区在线观看| 亚洲日本乱码在线观看| 亚洲丶国产丶欧美一区二区三区| 午夜视频在线观看一区二区| 国产日韩一区二区三区在线播放 | 一区二区三区欧美日韩| 亚洲乱码国产乱码精品精| 亚洲欧洲精品一区二区三区波多野1战4 | 亚洲电影欧美电影有声小说| 久久精品国亚洲| 玖玖玖国产精品| 日韩一级欧洲| 亚洲午夜免费视频| 国产综合色在线视频区| 亚洲第一精品夜夜躁人人爽| 久久伊人免费视频| 亚洲伊人久久综合| 国内成+人亚洲| av成人手机在线| 亚洲成人在线网站| 亚洲欧美日韩国产| 一区二区三区欧美在线| 久久成人免费网| 亚洲欧美在线高清| 欧美高清视频一区| 欧美成人免费网| 国产亚洲精品久久久久久| 亚洲日本久久| 亚洲精品在线一区二区| 亚洲欧美另类综合偷拍| 久久精品91久久久久久再现| 久久久午夜电影| 欧美中文字幕精品| 国产精品毛片va一区二区三区 | 一区二区在线不卡| 亚洲在线观看视频| 亚洲午夜av| 国产精品国产自产拍高清av王其| 亚洲国产mv| 91久久夜色精品国产网站| 久久免费视频在线观看| 老鸭窝毛片一区二区三区| 国内精品福利| 美女91精品| 亚洲图中文字幕| 欧美看片网站| 亚洲午夜久久久| 久久天天躁狠狠躁夜夜爽蜜月|