Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <deque>
- #include <complex>
- using namespace std;
- bool Kriterij (complex<double> z1, complex<double> z2)
- {
- if (abs(z1)==abs(z2)) return z1.real()<z2.real();
- else return abs(z1)<abs(z2);
- }
- int main () {
- int n;
- cout<<"Unesite n :";
- cin>>n;
- deque<complex<double>> d(0);
- cout<<"Unesite elemente deka u obliku (x,y): ";
- complex<double> z;
- for (int i=0; i<n; i++) {
- cin>>z;
- d.push_back(z);
- }
- sort(d.begin(), d.end(), Kriterij);
- for (auto x : d) cout<<x<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement