• <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>

            The Fourth Dimension Space

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

            復數類模板final(6.0下可用)

            #include<iostream.h>
            #include
            <cstdio>
            #include
            <cmath>

            //本模板在VC6.0下可正常運行
            //注意,想6.0支持友元函數,需要使用iostream.h并去掉using namespace std;聲明進行編譯。
            /*//////////////////////////////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:49 abilitytao 閱讀(243) 評論(0)  編輯 收藏 引用

            久久精品国产精品亜洲毛片| 国产精品久久99| 亚洲国产精品久久久久久| 无码人妻久久一区二区三区| 中文国产成人精品久久不卡| 中文字幕久久精品| 国产成人久久精品一区二区三区| 久久这里只精品99re66| 久久亚洲熟女cc98cm| 久久亚洲中文字幕精品一区四 | 亚洲精品NV久久久久久久久久 | 国产精品成人99久久久久 | 天天爽天天狠久久久综合麻豆| 精品无码久久久久国产动漫3d| 婷婷国产天堂久久综合五月| 久久天天躁夜夜躁狠狠| 欧美午夜精品久久久久免费视| 久久午夜无码鲁丝片| 久久夜色tv网站| 久久综合成人网| 无码人妻久久一区二区三区| 97久久天天综合色天天综合色hd| 777久久精品一区二区三区无码| 久久婷婷色综合一区二区| 欧美亚洲国产精品久久高清| AV色综合久久天堂AV色综合在| 久久久久四虎国产精品| 亚洲国产精品无码久久青草 | 久久久久久亚洲AV无码专区| 91精品国产91久久久久久| 亚洲午夜精品久久久久久浪潮| 伊人久久大香线蕉综合Av| 777久久精品一区二区三区无码| 欧美性大战久久久久久| 久久精品国产亚洲AV无码娇色| 国产成人精品久久| 久久精品国产亚洲av水果派 | 亚洲欧美久久久久9999| 丁香五月网久久综合| 伊人精品久久久久7777| 91久久精品国产91性色也|