Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- class Sortiraj{
- public:
- bool operator()(int a, int b){
- return a < b;
- }
- };
- int main(){
- // 1. zadatak
- // umjesto ? napisati funkcijski objekt a zatim i lambda izraz kojim se vektor
- // x sortira od najmanje vrijednosti prema većoj
- vector<int> x = { 3, -1, 0, 4, 1 };
- sort(x.begin(), x.end(), Sortiraj());
- for (int i = 0; i < x.size(); i++){
- cout << x[i] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement