Advertisement
mbriski1

Untitled

May 24th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. class Sortiraj{
  7. public:
  8. bool operator()(int a, int b){
  9. return a < b;
  10. }
  11.  
  12. };
  13. int main(){
  14. // 1. zadatak
  15. // umjesto ? napisati funkcijski objekt a zatim i lambda izraz kojim se vektor
  16. // x sortira od najmanje vrijednosti prema većoj
  17. vector<int> x = { 3, -1, 0, 4, 1 };
  18. sort(x.begin(), x.end(), Sortiraj());
  19. for (int i = 0; i < x.size(); i++){
  20. cout << x[i] << " ";
  21. }
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement