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

The Fourth Dimension Space

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

復數類模板(Complex Class)

#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:39 abilitytao 閱讀(1758) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   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ⅴ色国产欧美| 久久久国产精品一区二区中文| 亚洲综合首页| 亚洲一区二区欧美| 亚洲欧美日韩精品久久久久| 欧美中文字幕不卡| 久久九九有精品国产23| 久久精品日产第一区二区三区| 欧美在线一二三| 久久综合久久综合这里只有精品| 久久青青草原一区二区| 奶水喷射视频一区| 日韩一级视频免费观看在线| 亚洲天堂网在线观看| 久久久99久久精品女同性| 欧美成人情趣视频| 欧美日韩亚洲激情| 国产日韩欧美在线| 亚洲电影专区| 亚洲午夜女主播在线直播| 午夜久久美女| 亚洲国产精品久久久| 99精品久久久| 久久久xxx| 国产精品第13页| 亚洲大片在线| 亚洲欧美在线视频观看| 国产精品豆花视频| 国产午夜精品理论片a级大结局| 伊人久久久大香线蕉综合直播| 亚洲免费电影在线| 久久久久久一区| 日韩手机在线导航| 久久久久综合一区二区三区| 欧美日韩一区不卡| 亚洲国产91色在线| 久久精品国产999大香线蕉| 欧美激情视频一区二区三区不卡| 夜夜嗨网站十八久久 | 日韩午夜精品| 欧美成人免费一级人片100| 91久久久亚洲精品| 欧美一区二区精品| 欧美日韩亚洲一区二| 国产目拍亚洲精品99久久精品| 欧美高清hd18日本| 欧美三区视频| 亚洲高清av在线| 亚洲尤物视频网| 免费观看国产成人| 亚洲专区免费| 欧美黄污视频| 国产一区二区精品久久99| 亚洲区中文字幕| 欧美亚洲视频| 亚洲裸体视频| 久久精品国产欧美激情| 欧美精品v日韩精品v国产精品| 亚洲国产日韩欧美在线动漫| 亚洲欧美成人网| 亚洲国产成人av在线| 午夜在线一区| 国产精品成人一区| 国产欧美日韩91| 99riav国产精品| 亚洲经典一区| 女主播福利一区| 欧美一级理论性理论a| 欧美日本韩国在线| 最新精品在线| 男男成人高潮片免费网站| 亚洲在线观看| 国产精品国产三级国产普通话三级| 国产专区欧美专区| 欧美一站二站| 亚洲国产高清在线| 久久久五月婷婷| 国内视频精品| 久久精品国产第一区二区三区最新章节 | 亚洲欧美日韩视频二区| 欧美激情亚洲国产| 欧美凹凸一区二区三区视频| 亚洲欧美国产视频| 国产精品v欧美精品v日韩精品| 亚洲黑丝在线| 欧美成年人网站| 牛牛影视久久网| 亚洲人人精品| 久久黄色级2电影| 校园春色国产精品| 欧美体内she精视频| 一区二区三区波多野结衣在线观看| 亚洲国产mv| 欧美激情欧美狂野欧美精品| 亚洲人成网站色ww在线| 亚洲黄一区二区三区| 欧美理论在线| 亚洲一区二区在| 亚洲欧美一区二区视频| 国产一级精品aaaaa看| 亚洲国产一区二区三区青草影视| 欧美成人一区二区三区片免费| 午夜日韩av| 欧美色另类天堂2015| 欧美一区二区三区久久精品茉莉花| 亚洲欧美日韩精品久久亚洲区 | 亚洲人成在线免费观看| 亚洲黄色成人网| 国产精品卡一卡二卡三| 久久精品国产免费看久久精品| 老色批av在线精品| 亚洲激情国产精品| 欧美三级视频在线| 久久久久久久久久久久久女国产乱 | 欧美一级片一区| 亚洲人成网站在线观看播放| 日韩亚洲欧美一区| 激情一区二区三区| 午夜精品999| 欧美精品高清视频| 久久国产精品网站| 欧美一区二区三区免费看| 久久久久亚洲综合| 亚洲婷婷免费| 久久夜色精品国产| 午夜在线成人av| 亚洲自拍啪啪| 亚洲看片一区| 午夜视频一区二区| 宅男在线国产精品| 理论片一区二区在线| 亚洲午夜视频在线观看| 久久欧美中文字幕| 激情成人亚洲| 欧美激情一区二区三区不卡| 久久资源av| 欧美日韩在线三区| 欧美在线日韩在线| 亚洲一区一卡| 老司机一区二区| 一区二区三区日韩欧美| 日韩亚洲欧美一区二区三区| 国精品一区二区三区| 99视频一区二区三区| 国产日本精品| 亚洲欧美国内爽妇网| 欧美成人免费一级人片100| 久久久久久久97| 欧美国产亚洲精品久久久8v| 玖玖精品视频| 一色屋精品视频在线看| 午夜欧美不卡精品aaaaa| 国产精品久久看| 亚洲一级在线| 亚洲一区欧美二区| 欧美怡红院视频一区二区三区| 先锋影音国产精品| 国产精品美女久久久久aⅴ国产馆| 老鸭窝亚洲一区二区三区| 国产欧美精品日韩| 亚洲欧美日韩在线观看a三区| 亚洲一区二区高清| 欧美亚洲成人网| 欧美国产日韩一区| 欧美www视频| 久久久久久一区二区三区| 欧美日韩中文字幕日韩欧美| 日韩一级二级三级| 韩日精品中文字幕| 久久夜色精品国产欧美乱| 男女激情久久| 99re8这里有精品热视频免费 | 99精品视频免费全部在线| 亚洲一区日韩在线| 国产精品综合色区在线观看| 欧美一区二区国产| 最新国产精品拍自在线播放| 免费毛片一区二区三区久久久| 欧美丰满高潮xxxx喷水动漫| 国产视频在线观看一区二区三区| 欧美一区二区三区在线视频| 美女91精品| 一区二区高清视频| 国产精品视频一区二区高潮| 亚洲精品国精品久久99热一| 亚洲男人第一网站| 国产精品电影网站| 欧美一区二区三区在线免费观看| 久久亚洲综合| 9色精品在线| 美女精品网站| 一本大道av伊人久久综合| 亚洲女同同性videoxma| 狠狠色狠色综合曰曰| 欧美精品三级| 久久福利一区| 99视频精品| 久久综合999| 亚洲一区二区在线| 亚洲性人人天天夜夜摸|