int main() { int n ; cin>>n; //double real=[1.6,1.6,7.5,6.4,3.8]; vector<Complex> vec(n); Complex x; for (int i = 0; i < vec.size(); i++){ x.assign((rand()%1000)/10.0,(rand()%1000/10.0)); vec[i]=x; cout << vec[i] << " "; } cout<<endl; n=vec[0]<vec[1]; cout<<n<<endl; sort(vec.begin(), vec.end()); for (int i = 0; i < vec.size(); i++){ cout << vec[i] << " "; } cout<<endl; return 0; }
Complex Complex::operator / (const Complex& a ){ float temp = a.real*a.real + a.image * a.image; Complex c ; c.assign( ( real * a.real + image * a.image ) / temp, ( image * a.real - real * a.image ) / temp ); return c ; }
Complex Complex::operator * (const Complex& a ){ Complex c ; c.assign( real * a.real - image * a.image, image * a.real + real * a.image); return c ; }
Complex Complex::operator - (const Complex& a ){ Complex c ; c.assign( real - a.real, image - a.image ) ; return c ; }
Complex Complex::operator + (const Complex& a ){ Complex c ; c.assign( real + a.real, image + a.image ); // cout << real + a.getReal() << " " << image + a.getImage(); return c ; }