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

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>
            亚洲午夜精品一区二区三区他趣 | 亚洲尤物精选| 免费黄网站欧美| 国产精品视频一区二区三区| 欧美午夜不卡在线观看免费 | 久久免费黄色| 日韩视频免费在线| 99热这里只有成人精品国产| 欧美高清视频免费观看| 欧美成人精品在线观看| 免费在线欧美视频| 亚洲全部视频| 91久久久国产精品| 亚洲国产一区二区a毛片| 一本久久综合亚洲鲁鲁| 亚洲美女中出| 欧美在线啊v一区| 久久一区二区三区国产精品| 欧美freesex8一10精品| 国产精品成人在线| 国产精品欧美久久久久无广告| 国产午夜精品一区二区三区欧美| 欧美日韩综合| 欧美日韩免费一区二区三区| 国产欧美另类| 亚洲高清自拍| 久久国产精品电影| 欧美成人一区二区| 亚洲欧美日韩精品久久亚洲区 | 欧美一区二区免费观在线| 久久国产精品一区二区三区| 久久久91精品| 久久亚洲精选| 欧美午夜久久| 国产性猛交xxxx免费看久久| 一本色道久久综合亚洲二区三区| 性欧美办公室18xxxxhd| 亚洲高清免费视频| 亚洲网在线观看| 欧美成人精品福利| 国产精品久久久一区二区三区| 国产一区二区三区日韩欧美| 亚洲一级黄色av| 久久亚洲国产精品一区二区| 亚洲精选在线| 久久亚洲国产精品日日av夜夜| 欧美日韩精品欧美日韩精品一| 亚洲国产精品第一区二区| 亚洲男人的天堂在线观看| 亚洲人成在线播放| 久久精品国产亚洲一区二区| 国产欧美91| 亚洲私人影院| 日韩亚洲在线观看| 美女啪啪无遮挡免费久久网站| 欧美日韩在线免费| 正在播放日韩| 欧美黄网免费在线观看| 久久激情综合网| 99这里只有久久精品视频| 久久av一区| 亚洲欧美综合国产精品一区| 亚洲先锋成人| 欧美jjzz| 在线观看中文字幕不卡| 欧美一区二区在线视频| 夜夜嗨av一区二区三区| 美日韩在线观看| 国产综合色在线视频区| 亚洲一区二区三区在线观看视频| 欧美在线视频日韩| 久久国产天堂福利天堂| 国产精品免费网站在线观看| 午夜欧美大片免费观看| 99在线|亚洲一区二区| 久久成人久久爱| 亚洲第一精品在线| 久久亚洲精品一区二区| 欧美a级片一区| 亚洲精品综合精品自拍| 久热精品视频| 欧美黄色一级视频| 亚洲欧洲精品一区二区精品久久久 | 麻豆成人综合网| 国产一区二区0| 亚洲国产精品一区制服丝袜| 久久人91精品久久久久久不卡 | 亚洲国产女人aaa毛片在线| 欧美大片在线看| 最新日韩在线视频| 亚洲欧美国产不卡| 国产日韩欧美一区二区| 欧美成人精品一区| 欧美精品一卡| 亚洲欧美精品suv| 另类酷文…触手系列精品集v1小说| 在线观看欧美| 亚洲黑丝在线| 欧美ab在线视频| 亚洲男同1069视频| 久久精品人人爽| 欧美粗暴jizz性欧美20| 亚洲午夜精品17c| 一区二区三区欧美日韩| 精品1区2区3区4区| 欧美激情网友自拍| 国产亚洲成精品久久| 久久躁狠狠躁夜夜爽| 久久精精品视频| 午夜一区不卡| 久久先锋影音| 亚欧成人精品| 久久综合色88| 亚洲欧美日韩国产一区二区三区| 午夜精品免费在线| 久久精品夜色噜噜亚洲aⅴ| 欧美刺激午夜性久久久久久久| 在线观看亚洲视频| 亚洲日韩中文字幕在线播放| 国产精品久久一级| 欧美69视频| 国产欧美日韩| 日韩视频不卡| 在线不卡亚洲| 亚洲视频第一页| 亚洲精品免费一区二区三区| 亚洲欧美视频在线观看视频| 亚洲黄网站黄| 欧美在线欧美在线| 国产精品99久久久久久久vr| 久久久免费观看视频| 亚洲主播在线观看| 欧美激情精品久久久久| 久久人人爽人人爽爽久久| 欧美日韩亚洲三区| 亚洲国产精品久久人人爱蜜臀| 合欧美一区二区三区| 亚洲小视频在线| 一本久道久久久| 牛牛影视久久网| 久久综合中文字幕| 国产亚洲精品bv在线观看| 一区二区三区 在线观看视| 亚洲激情网站免费观看| 久久国产主播精品| 久久久久免费| 最新国产の精品合集bt伙计| 老司机精品视频一区二区三区| 久久精品国产v日韩v亚洲| 国产午夜亚洲精品羞羞网站| 亚洲午夜精品久久久久久app| 亚洲欧美激情一区二区| 欧美午夜激情视频| 亚洲在线免费视频| 欧美一区国产一区| 亚洲久久成人| 欧美一区二区三区四区在线观看| 欧美色中文字幕| 久久狠狠一本精品综合网| 性色av香蕉一区二区| 影音先锋中文字幕一区| 久久激情综合网| 亚洲每日更新| 亚洲影院免费观看| 国产欧美一区二区三区另类精品| 亚洲天堂网在线观看| 午夜亚洲一区| 国产精品第一区| 久久精精品视频| 亚洲福利专区| 一本色道久久综合亚洲91| 国产麻豆午夜三级精品| 午夜一区在线| 欧美一区二区啪啪| 在线国产日韩| 欧美精品综合| 久久久久久久网站| 亚洲高清三级视频| 久久国产精品99精品国产| 韩国av一区二区三区在线观看| 欧美成人乱码一区二区三区| 亚洲人屁股眼子交8| 久久久久国产精品麻豆ai换脸| 欧美国产三区| 亚洲午夜在线视频| 在线观看欧美亚洲| 欧美激情按摩在线| 欧美在线视频观看| 亚洲电影视频在线| 欧美一区三区三区高中清蜜桃| 黄色欧美日韩| 国产精品一区二区久久精品| 欧美尤物一区| 亚洲影视中文字幕| 日韩视频在线一区二区| 国产欧美日韩综合| 欧美图区在线视频| 裸体素人女欧美日韩| 欧美亚洲三级| 夜夜嗨av一区二区三区四区|