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

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>
            一本一本久久a久久精品综合妖精 一本一本久久a久久精品综合麻豆 | 亚洲欧美国产精品va在线观看| 麻豆成人91精品二区三区| 亚洲精品国产欧美| 久久这里有精品视频| 欧美一区二区日韩| 亚洲免费在线| 久久精品九九| 蜜桃视频一区| 亚洲另类在线视频| 亚洲永久免费精品| 久久久久久久久久久久久女国产乱| 欧美一区二区高清| 亚洲一区二区三区精品在线| 伊人伊人伊人久久| 国产综合自拍| 亚洲精品一区二区三区四区高清| 曰韩精品一区二区| 99精品国产一区二区青青牛奶 | 久久久国产精彩视频美女艺术照福利 | 国产偷国产偷精品高清尤物| 国产日韩欧美日韩| 99re热精品| 久久久成人网| 99riav1国产精品视频| 久久狠狠一本精品综合网| 欧美日韩不卡在线| 亚洲国产成人av好男人在线观看| 亚洲精品综合在线| 久久中文字幕一区| 欧美一区二区三区在线看| 欧美高清视频免费观看| 国产性天天综合网| 欧美在现视频| 亚洲女人天堂成人av在线| 欧美日韩视频不卡| 亚洲免费观看高清完整版在线观看| 久久av资源网站| 亚洲香蕉网站| 国产精品视频久久| 欧美呦呦网站| 久久国产欧美精品| 在线播放国产一区中文字幕剧情欧美 | 日韩一级在线观看| 91久久精品国产91久久| 美国三级日本三级久久99| …久久精品99久久香蕉国产| 久久综合一区二区| 美女日韩欧美| 亚洲一区二区三区乱码aⅴ蜜桃女| 亚洲精品欧美日韩| 欧美日韩成人综合| 欧美亚洲视频在线看网址| 翔田千里一区二区| 亚洲激情国产精品| 一卡二卡3卡四卡高清精品视频 | 亚洲综合视频在线| 国内精品久久久久久久影视蜜臀| 久久精品一二三| 欧美激情1区2区| 久久久五月婷婷| 欧美日韩免费观看一区=区三区| 亚洲一区二区三区在线播放| 久久精品1区| 先锋影音久久久| 欧美国产一区视频在线观看| 久久av资源网| 国产精品视频网址| 亚洲美女av在线播放| 激情一区二区| 欧美一区二区三区久久精品| 亚洲一区二区三区精品在线| 免费av成人在线| 另类欧美日韩国产在线| 国产日韩欧美另类| 欧美专区在线| 国产精品久久久久久久久免费| 久久精品国产综合| 国产毛片精品国产一区二区三区| 日韩亚洲欧美一区| 亚洲视频免费| 国产精品亚洲网站| 欧美一区二区三区在线免费观看 | 国产精品女主播在线观看| 亚洲破处大片| 亚洲欧美偷拍卡通变态| 国产精品视频一二三| 久久国产婷婷国产香蕉| 麻豆91精品| 99国产一区| 国产一区二区三区电影在线观看| 亚洲一区久久| 久久中文字幕导航| 亚洲一区二区三区中文字幕| 国产日韩成人精品| 欧美成人免费小视频| 亚洲视频免费在线| 美女黄毛**国产精品啪啪| 亚洲人在线视频| 国产乱人伦精品一区二区| 久久精品首页| 亚洲视频精品在线| 亚洲国产另类久久久精品极度| 亚洲欧美色一区| 亚洲精品一级| 91久久精品国产91性色tv| 国产女精品视频网站免费| 欧美久久久久久久| 久久色中文字幕| 欧美在线观看一二区| 夜夜爽夜夜爽精品视频| 免费亚洲一区| 欧美成人四级电影| 国产精品国产三级国产| 免费成人av| 蜜桃视频一区| 免费成人黄色av| 久久久亚洲影院你懂的| 亚洲欧美在线播放| 亚洲在线观看免费| 亚洲自拍偷拍麻豆| 亚洲小视频在线| 亚洲综合精品一区二区| 亚洲一区二区三区四区五区黄| 亚洲国产免费| 99综合在线| 亚洲欧美激情视频| 久久久久久穴| 欧美日韩国产限制| 国内精品免费在线观看| 在线日韩欧美| 在线综合亚洲欧美在线视频| 午夜精品久久久久影视| 久久激情综合| 亚洲精品国久久99热| 亚洲欧洲av一区二区| 蜜桃av一区二区| 国产精品美女主播| 亚洲精品国产精品国自产在线| 在线亚洲精品| 亚洲二区视频在线| 亚洲欧美文学| 国产精品久久久久久av福利软件| 一区二区三区自拍| 午夜精品国产更新| 亚洲日本中文字幕| 久久久精品一区二区三区| 国产精品美女主播| 亚洲一区二区三区在线看| 亚洲电影有码| 男人的天堂亚洲| 亚洲高清在线观看| 农夫在线精品视频免费观看| 亚洲欧美日韩在线不卡| 国产精品久线观看视频| 亚洲一级黄色| 亚洲伊人一本大道中文字幕| 免费不卡欧美自拍视频| 性欧美videos另类喷潮| 国产精品久久久一区二区| 亚洲调教视频在线观看| 9久草视频在线视频精品| 欧美日韩国语| 午夜视频一区在线观看| 久久av资源网站| 在线播放亚洲一区| 亚洲国产日韩欧美在线图片| 蜜臀a∨国产成人精品| 亚洲免费观看高清完整版在线观看熊| 免费日韩成人| 国产精品美女久久久久久2018| 亚洲欧美在线一区二区| 久久久久国产精品www| 在线综合+亚洲+欧美中文字幕| 亚洲婷婷综合色高清在线| 一区二区三区在线免费视频| 亚洲韩国精品一区| 国产日韩亚洲欧美综合| 欧美国产日产韩国视频| 国产精品成人观看视频国产奇米| 久久久97精品| 国产精品一区三区| 亚洲精品国产无天堂网2021| 国模套图日韩精品一区二区| 亚洲欧洲一区| 1769国产精品| 欧美一乱一性一交一视频| av成人黄色| 麻豆精品国产91久久久久久| 欧美在线播放一区| 欧美调教vk| 中文国产成人精品| 一区二区三区精品在线| 欧美国产综合视频| 亚洲高清av在线| 亚洲精选一区二区| 欧美精品乱人伦久久久久久| 亚洲国产精品久久人人爱蜜臀| 狠狠色香婷婷久久亚洲精品| 久久久久欧美|