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

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>
            国产精品久久久久久亚洲调教| 一区二区三区.www| 欧美亚洲免费电影| 亚洲欧洲日产国产网站| 久久国产精品黑丝| 亚洲欧美日韩一区二区在线| 99视频一区二区| 亚洲狼人综合| 一区二区动漫| 午夜精品久久久| 亚洲图片欧美日产| 亚洲欧美成人一区二区在线电影| 亚洲视频你懂的| 夜夜精品视频| 香蕉久久精品日日躁夜夜躁| 亚洲欧美文学| 久久激情视频| 久久久久久久成人| 女人香蕉久久**毛片精品| 老司机精品视频网站| 麻豆久久久9性大片| 亚洲视频碰碰| 久久久久久久999精品视频| 久久久综合网站| 久久久久久久波多野高潮日日| 久久久久久亚洲精品杨幂换脸| 美腿丝袜亚洲色图| 亚洲免费精品| 久久婷婷人人澡人人喊人人爽| 欧美韩日精品| 国产精品盗摄久久久| 国产性猛交xxxx免费看久久| 亚洲人成在线播放| 日韩一区二区福利| 午夜精品久久久| 欧美激情精品久久久久久蜜臀 | 欧美日韩国产精品成人| 国产美女精品视频| 日韩亚洲欧美在线观看| 久久精品国产一区二区三区免费看| 免费在线看一区| 免费在线亚洲欧美| 亚洲国产成人tv| 99riav1国产精品视频| 一本色道精品久久一区二区三区| 一本色道久久88综合亚洲精品ⅰ | 亚洲欧美日韩国产成人| 蜜月aⅴ免费一区二区三区 | 亚洲人成毛片在线播放女女| 香蕉久久夜色精品国产| 亚洲国产福利在线| 欧美一区二区三区四区视频| 欧美寡妇偷汉性猛交| 黄色亚洲免费| 一区二区三区欧美亚洲| 午夜精品久久久久久久99樱桃| 久久综合中文| 国产欧美精品一区| 亚洲一级黄色av| 亚洲日本成人在线观看| 久久久久综合网| 国产欧美日韩综合精品二区| 亚洲午夜激情网页| 亚洲精品色图| 欧美激情在线播放| 亚洲精品美女免费| 亚洲国产精品va在线看黑人动漫| 久久麻豆一区二区| 在线不卡a资源高清| 久久久午夜视频| 欧美亚洲免费电影| 国产亚洲精品自拍| 伊人久久久大香线蕉综合直播| 日韩视频免费在线观看| 久久天天躁狠狠躁夜夜爽蜜月| 亚洲在线一区二区| 欧美成人一区二区在线| 国内久久精品| 久久久99精品免费观看不卡| 欧美日韩国产区| 国产亚洲欧美一区二区三区| 亚洲欧美日韩在线观看a三区| 亚洲精品在线免费| 欧美精品电影| 亚洲午夜精品久久久久久浪潮| 亚洲精品社区| 国产精品黄色| 欧美在线|欧美| 亚洲伊人伊色伊影伊综合网 | 久久久999精品免费| 国产农村妇女精品| 午夜在线一区| 欧美在线播放一区| 国产一区二区av| 久久本道综合色狠狠五月| 午夜亚洲性色视频| 精品电影一区| 欧美国产一区二区三区激情无套| 欧美a级片网站| 日韩一级免费| 亚洲免费视频在线观看| 国内精品美女在线观看| 欧美激情亚洲自拍| 国产精品草草| 久久久国产视频91| 麻豆免费精品视频| 欧美寡妇偷汉性猛交| 亚洲激情校园春色| 亚洲国产精品成人一区二区 | 久久久久久日产精品| 美女久久一区| 午夜精品999| 久久只有精品| 亚洲欧美三级伦理| 欧美v国产在线一区二区三区| 亚洲无亚洲人成网站77777 | 欧美国产精品久久| 国产一区二区毛片| 在线午夜精品| 一区二区三区精密机械公司 | 亚洲午夜电影在线观看| 亚洲精品影院| 美日韩精品免费| 久久综合伊人77777蜜臀| 国产日产精品一区二区三区四区的观看方式 | 欧美风情在线| 校园激情久久| 欧美色播在线播放| 亚洲国产专区校园欧美| 国产亚洲欧美激情| 亚洲一区3d动漫同人无遮挡| 亚洲二区精品| 欧美一区2区视频在线观看 | 久久成人18免费观看| 亚洲性视频网站| 亚洲欧美日韩在线一区| 欧美一区免费视频| 亚洲激情第一区| 99视频热这里只有精品免费| 久久狠狠亚洲综合| 欧美自拍丝袜亚洲| 久久国产天堂福利天堂| 亚洲激情综合| 在线中文字幕一区| 欧美一级专区| 免费不卡欧美自拍视频| 在线视频你懂得一区二区三区| 一区二区三区黄色| 激情六月综合| 欧美国产成人精品| 性欧美在线看片a免费观看| 久久精品伊人| 亚洲小少妇裸体bbw| 亚洲免费一级电影| 日韩视频不卡| 久久久久成人精品| 亚洲在线中文字幕| 国内精品久久久久久久果冻传媒| 亚洲人成免费| 国产婷婷一区二区| 亚洲精品久久久久久下一站| 欧美一区国产一区| 欧美高清在线一区| 国产欧美日本一区二区三区| 欧美激情中文字幕一区二区| 欧美午夜不卡视频| 久久久久久久999精品视频| 一区二区三区回区在观看免费视频| 欧美一级在线亚洲天堂| 亚洲午夜精品一区二区| 欧美制服丝袜| 日韩午夜免费| 在线播放日韩| 欧美一级视频免费在线观看| 99伊人成综合| 欧美第十八页| 午夜伦理片一区| 亚洲一区二区三区在线视频| 久热国产精品| 老司机精品视频一区二区三区| 一区二区三区免费网站| 久久久夜精品| 狂野欧美一区| 国产午夜亚洲精品不卡| 亚洲一区二区三区在线看 | 欧美在线日韩在线| 嫩草影视亚洲| 久久久久一区| 国产精品中文字幕欧美| 亚洲免费小视频| 性欧美超级视频| 国产精品一区二区欧美| 亚洲欧美日韩成人| 黄色国产精品| 国产欧美精品久久| 久久久久久久欧美精品| 久热精品视频在线观看一区| 伊人激情综合| 黑人巨大精品欧美一区二区| 久久精品人人做人人综合|