Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <list>
- #include <iostream>
- using namespace std;
- struct comparer {
- int this_node;
- comparer(int node) : this_node(node) {} // wtf? är det här ok?
- bool operator()(int a, int b) {
- return (a+this_node > b);//(d(this_node,a) < d(this_node,b));
- }
- };
- int main()
- {
- int foo[] = {55, 22, 33, 11, -11, -33};
- list<int> mylist (foo, foo+sizeof(foo)/sizeof(int));
- mylist.sort(comparer(32));
- for (list<int>::iterator it=mylist.begin(); it!=mylist.end(); ++it)
- cout << " " << *it;
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment