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

The Fourth Dimension Space

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

Complex Class (Beta 2.0)

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


//本模板在VS2005下可正常運(yùn)行
/*//////////////////////////////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) 評(píng)論(5)  編輯 收藏 引用

評(píng)論

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

STL中不是有complex類(lèi)么,為什么要自己搞個(gè)。歡迎加入QQ群 36071431 討論C++問(wèn)題。  回復(fù)  更多評(píng)論   

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

@playcpp
為了練習(xí)運(yùn)算符重載 呵呵 這個(gè)理由怎么樣  回復(fù)  更多評(píng)論   

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

練運(yùn)算符重載應(yīng)該寫(xiě)高精度計(jì)算。  回復(fù)  更多評(píng)論   

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

@WindyWinter
那個(gè)有點(diǎn)麻煩呢 呵呵 你知道高精度浮點(diǎn)類(lèi)要怎么寫(xiě)嗎?  回復(fù)  更多評(píng)論   

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

有些可以?xún)?nèi)聯(lián)調(diào)用,需要考慮除零問(wèn)題,高精度浮點(diǎn)類(lèi)搜索bcd  回復(fù)  更多評(píng)論   


只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   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| 亚洲在线一区二区| 亚洲欧美激情四射在线日| 亚洲欧美久久| 久久大逼视频| 开心色5月久久精品| 男男成人高潮片免费网站| 欧美成人在线免费观看| 亚洲经典在线| 99亚洲视频| 亚洲一区二区三区涩| 久久国产精品黑丝| 母乳一区在线观看| 国产精品久久777777毛茸茸| 国产精品主播| 91久久久亚洲精品| 一区二区三区精品视频| 久久精品在线观看| 亚洲黄色av| 久久成人人人人精品欧| 欧美精品一卡| 一区二区三区在线观看欧美| 在线亚洲观看| 久久综合99re88久久爱| 一区二区三区四区五区精品视频| 欧美一级电影久久| 欧美三级韩国三级日本三斤| 激情成人在线视频| 午夜精彩视频在线观看不卡| 欧美国产日本在线| 亚洲欧美中日韩| 欧美激情综合亚洲一二区 | 亚洲精品日韩久久| 亚洲欧美亚洲| 欧美日韩一级大片网址| 在线色欧美三级视频| 午夜久久影院| 91久久久久久国产精品| 久久精品日韩一区二区三区| 国产精品久久久久一区二区| 亚洲精品美女91| 久久天天躁狠狠躁夜夜av| 亚洲国产高潮在线观看| 久久av一区二区三区| 国产精品视频你懂的| 国产精品99久久久久久久久久久久| 免费91麻豆精品国产自产在线观看| 亚洲特级片在线| 欧美精品在线免费播放| 亚洲人成7777| 亚洲人成网站在线播| 久久综合一区二区三区| 亚洲国产女人aaa毛片在线| 国产综合色产在线精品| 欧美一区二区视频在线观看| 日韩特黄影片| 欧美日韩成人在线视频| 99国产精品视频免费观看| 亚洲成色777777在线观看影院| 欧美在线观看一区| 国语自产偷拍精品视频偷| 久久久久久午夜| 欧美在线免费一级片| 国产日韩欧美夫妻视频在线观看| 欧美一级大片在线观看| 香蕉视频成人在线观看| 国外成人性视频| 蜜桃久久精品一区二区| 久久久美女艺术照精彩视频福利播放| 国产一区清纯| 欧美激情第10页| 欧美国产精品劲爆| 99精品久久久| 亚洲天堂av电影| 国产一区91| 欧美黄免费看| 欧美日韩视频第一区| 亚洲永久免费精品| 午夜欧美大片免费观看 | 久久最新视频| 一本大道久久精品懂色aⅴ| 亚洲免费成人| 国产色视频一区| 欧美黑人国产人伦爽爽爽| 欧美日韩成人免费| 欧美一区二区精品久久911| 久久一区亚洲| 亚洲一区二区在线免费观看视频 | 国产精品乱码一区二三区小蝌蚪| 欧美主播一区二区三区美女 久久精品人 | 欧美激情一区二区| 国产精品av一区二区| 久久综合亚州| 欧美日韩免费网站| 久久久久青草大香线综合精品| 欧美高清在线视频观看不卡| 性色一区二区三区| 免费成人性网站| 欧美一区高清| 欧美激情国产高清| 久久综合伊人77777| 国产精品地址| 最新国产精品拍自在线播放| 精品动漫3d一区二区三区免费版 | 欧美日韩在线一区二区三区| 欧美一区二区三区在线视频| 欧美激情一区二区三区在线| 久久国产精品毛片| 欧美福利视频一区| 久久久人成影片一区二区三区| 欧美日韩在线精品| 亚洲二区在线观看| 国产视频亚洲精品| 99国内精品久久| 亚洲精品美女免费| 久久精品三级| 久久亚洲视频| 激情文学综合丁香| 亚洲欧美在线免费| 午夜亚洲激情| 国产精品久久久久一区二区三区| 亚洲精品一区二区三区在线观看 | 亚洲欧美日韩国产中文| 亚洲永久精品国产| 欧美日韩午夜视频在线观看| 亚洲成色777777女色窝| 亚洲国产经典视频| 麻豆av福利av久久av| 久久综合精品国产一区二区三区| 国产精品私人影院| 亚洲男人的天堂在线aⅴ视频| 亚洲自拍偷拍一区| 国产精品稀缺呦系列在线| 亚洲一区二区成人在线观看| 亚洲综合国产| 国产精品欧美激情| 亚洲综合色网站| 久久精品日产第一区二区| 国产亚洲网站| 久久久久综合一区二区三区| 欧美成人精品h版在线观看| 亚洲国产日韩美| 欧美久久久久久| 99国产精品视频免费观看| 午夜精彩国产免费不卡不顿大片| 国产麻豆视频精品| 久久国产免费| 亚洲国产成人不卡| 亚洲一区二区三区在线播放| 国产精品夜夜嗨| 久久xxxx精品视频| 欧美不卡一卡二卡免费版| 99精品久久久| 国产精品综合久久久| 久久精品卡一| 日韩亚洲成人av在线| 欧美影院在线播放| 亚洲国产精品精华液网站| 欧美视频福利| 久久综合999| 在线综合亚洲欧美在线视频| 久久精品免费观看| 亚洲人永久免费| 国产欧美日韩一级| 欧美高清自拍一区| 欧美精品久久99| 亚洲高清在线| 亚洲在线黄色| 国产自产女人91一区在线观看| 久久亚洲一区二区三区四区| 亚洲美女av网站| 久久不射电影网| 99天天综合性| 国产在线观看91精品一区| 欧美激情网友自拍| 欧美在线播放| 国产精品99久久久久久久久 | 日韩视频免费| 国产一区二区三区黄视频| 欧美日本二区| 久久美女性网| 亚洲一区二区在线| 亚洲福利视频专区| 久久爱另类一区二区小说| 这里只有视频精品| 亚洲电影免费观看高清| 国产精品专区第二| 欧美天天在线| 欧美激情亚洲一区| 久久综合色播五月| 欧美一二三区精品| 亚洲欧美日韩精品在线| 一区二区三区产品免费精品久久75 | 国产精品美女午夜av| 欧美成人免费在线| 久久久综合精品|