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

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>
            午夜国产精品影院在线观看| 伊人狠狠色j香婷婷综合| 91久久久久久| 久久精品国产清高在天天线| 亚洲免费观看高清完整版在线观看熊| 亚洲欧洲一区二区在线观看| 在线看欧美视频| 最近中文字幕mv在线一区二区三区四区| 亚洲国产国产亚洲一二三| 亚洲激情在线观看| 99在线精品视频| 亚洲欧美精品在线观看| 久久久久国色av免费观看性色| 久久精品一区二区国产| 欧美成人精品h版在线观看| 欧美激情在线播放| 宅男噜噜噜66一区二区66| 亚洲一区二区视频在线观看| 免费不卡欧美自拍视频| 亚洲国产精品一区二区第四页av| 亚洲伦理一区| 欧美一级大片在线观看| 久久一区二区三区四区五区| 一区二区三区四区五区视频 | 亚洲尤物在线视频观看| 亚洲免费视频观看| 久久亚洲色图| 国产精品女主播| 亚洲高清资源综合久久精品| 亚洲一区二区高清| 美女主播一区| 蜜月aⅴ免费一区二区三区| 亚洲最新在线视频| 久久一区二区三区四区五区| 欧美亚洲色图校园春色| 久久青青草综合| 欧美日韩在线三级| 国产日韩精品在线观看| 欧美亚洲一区| 麻豆成人在线观看| 一二三区精品| 一区二区动漫| 麻豆国产精品777777在线| 日韩午夜免费视频| 免费观看一级特黄欧美大片| 伊人久久大香线| 亚洲一级二级在线| 欧美精品在线免费观看| 曰韩精品一区二区| 久久久精品动漫| 亚洲淫性视频| 欧美色欧美亚洲另类二区 | 国产日韩在线视频| 99re6这里只有精品| 免费成人高清| 久久电影一区| 国产一区在线播放| 性欧美18~19sex高清播放| 99精品视频免费观看| 欧美国产日韩在线观看| 亚洲韩国精品一区| 免费成人黄色av| 美女国产一区| 亚洲国产视频a| 欧美日韩免费观看一区三区| 亚洲日韩成人| 亚洲国产精品成人精品| 欧美成人午夜视频| 亚洲精品国产精品国自产观看| 女主播福利一区| 久久婷婷国产综合尤物精品| 在线免费观看日本一区| 欧美国产日产韩国视频| 欧美成人黑人xx视频免费观看| 国产日韩专区| 亚洲视频在线一区| 亚洲午夜av| 国产日韩专区在线| 欧美jizzhd精品欧美巨大免费| 欧美91福利在线观看| av不卡在线看| 亚洲欧洲视频| 国产精品国产三级国产专区53| 亚洲视频专区在线| 久久国产精品久久w女人spa| 一本色道久久综合一区| 久久精品国产成人| 亚洲午夜日本在线观看| 久久久久se| 亚洲国产综合在线| 国产一区香蕉久久| 影音先锋一区| 亚洲欧洲在线播放| 国产精品一区二区在线| 欧美亚洲视频| 欧美sm视频| 午夜精品成人在线| 欧美专区福利在线| 一区二区三区四区蜜桃| 亚洲一级黄色av| 亚洲视频欧美视频| 在线观看中文字幕亚洲| 一区二区三区四区五区精品视频| 国产婷婷色一区二区三区四区| 亚洲高清免费视频| 国产精品theporn88| 欧美gay视频激情| 国产精品免费区二区三区观看| 久热精品在线视频| 国产精品爱啪在线线免费观看| 美女精品网站| 国产色视频一区| 亚洲激情视频网站| 精品99一区二区| 亚洲淫性视频| 亚洲免费在线视频| 欧美成人午夜激情视频| 免费一级欧美片在线播放| 国产精品免费在线| 亚洲精品一区二区三区蜜桃久| 国内一区二区在线视频观看| 一区二区三区视频观看| 99视频热这里只有精品免费| 久久先锋影音| 久久综合久久久久88| 国产精品视频yy9099| 亚洲免费大片| 日韩一区二区精品葵司在线| 美国三级日本三级久久99| 久久久激情视频| 国产美女一区| 亚洲综合精品四区| 99国产精品国产精品久久 | 欧美影院在线| 欧美性猛交xxxx乱大交退制版| 亚洲国产精品久久久久秋霞不卡| 午夜在线a亚洲v天堂网2018| 国产一区视频网站| 欧美日韩在线一区二区三区| 葵司免费一区二区三区四区五区| 亚洲影音一区| 欧美一级一区| 久久国产精品电影| 久久综合色88| 久久亚洲春色中文字幕久久久| 农夫在线精品视频免费观看| 欧美成人综合网站| 亚洲一二区在线| 午夜精品三级视频福利| 国产精品一区二区在线观看不卡| 亚洲一区二区在线视频| 欧美一区二区三区在线| 国产亚洲精品高潮| 久久精品国产清高在天天线| 久久久久久穴| 狠狠色2019综合网| 久久综合福利| 国产亚洲a∨片在线观看| 99一区二区| 久久精品视频99| 精品成人国产| 欧美日韩一区二区精品| 亚洲网站在线播放| 久久久蜜臀国产一区二区| 在线不卡中文字幕| 欧美精品日本| 亚洲一区二区三区777| 麻豆精品在线播放| 99视频一区| 狠狠做深爱婷婷久久综合一区| 免费亚洲一区二区| 亚洲中字在线| 亚洲成色www8888| 亚洲欧美卡通另类91av| 黄页网站一区| 欧美日韩一区二区在线观看视频| 亚洲欧美日韩在线播放| 欧美成人激情在线| 亚洲欧美电影在线观看| 国产精品久久久久久av下载红粉| 久久成人18免费观看| 欧美激情中文字幕在线| 亚洲欧美日韩精品| 亚洲高清精品中出| 国产老女人精品毛片久久| 免费观看30秒视频久久| 亚洲免费视频一区二区| 欧美黄色一区| 久久久久久一区二区| 中国亚洲黄色| 亚洲乱码国产乱码精品精98午夜| 国产麻豆精品久久一二三| 欧美人与禽猛交乱配视频| 久久se精品一区二区| 亚洲一区二区三区在线视频| 最新国产精品拍自在线播放| 暖暖成人免费视频| 久久亚洲视频| 久久久久久久综合日本| 宅男噜噜噜66国产日韩在线观看|