Advertisement
naskedvi

S5 - zad.26

Apr 26th, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <complex>
  4. typedef std::complex<double> Kompleksni;
  5.  
  6. bool Manji(Kompleksni x, Kompleksni y)
  7. {
  8.     return std::arg(x)<std::arg(y);
  9. }
  10.  
  11. int main()
  12. {
  13.     std::cout<<"Unesi broj elemenata: ";
  14.     int n;
  15.     std::cin>>n;
  16.     std::vector<Kompleksni> v(n);
  17.     std::cout<<std::endl<<"Unesi kompleksne brojeve:"<<std::endl;
  18.     for(int i=0; i<n; i++)
  19.         std::cin>>v[i];
  20.  
  21.     std::sort(std::begin(v), std::end(v), Manji);
  22.  
  23.     for(int i=0; i<n; i++)
  24.       std::cout<<v[i]<<" ";
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement