看看 stl============================================================
最新自动计时定时开关机的软件 Timer Explorer 6.0 发布
下载主页: http://www.timeearth.com
============================================================

解决方案 »

  1.   

    a+bi的模为sqrt(a*a+b*b)
    标准c++没提供这个函数
      

  2.   

    #include<complex>
    std::complex这个类
      

  3.   

    template<class T>
        class complex {
    public:
        typedef T value_type;
        T real() const;
        T imag() const;
        complex(const T& re = 0, const T& im = 0);
        complex(const complex& x);
        complex& operator=(const complex& rhs);
        complex& operator+=(const complex& rhs);
        complex& operator-=(const complex& rhs);
        complex& operator*=(const complex& rhs);
        complex& operator/=(const complex& rhs);
        complex& operator=(const T& rhs);
        complex& operator=(const T& rhs);
        complex& operator+=(const T& rhs);
        complex& operator-=(const T& rhs);
        complex& operator*=(const T& rhs);
        complex& operator/=(const T& rhs);
        friend complex<T>
            operator+(const complex<T>& lhs, const T& rhs);
        friend complex<T>
            operator+(const T& lhs, const complex<T>& rhs);
        friend complex<T>
            operator-(const complex<T>& lhs, const T& rhs);
        friend complex<T>
            operator-(const T& lhs, const complex<T>& rhs);
        friend complex<T>
            operator*(const complex<T>& lhs, const T& rhs);
        friend complex<T>
            operator*(const T& lhs, const complex<T>& rhs);
        friend complex<T>
            operator/(const complex<T>& lhs, const T& rhs);
        friend complex<T>
            operator/(const T& lhs, const complex<T>& rhs);
        friend bool operator==(const complex<T>& lhs, const T& rhs);
        friend bool operator==(const T& lhs, const complex<T>& rhs);
        friend bool operator!=(const complex<T>& lhs, const T& rhs);
        friend bool operator!=(const T& lhs, const complex<T>& rhs);
        };没取模函数,自己写吧
      

  4.   

    谁说没有复数取模的函数,我是下面这样做的:
    float a,b,c;
    struct _complex number = {a,b}
    c=_cabs(number);