Guest User

Untitled

a guest
May 24th, 2012
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <algorithm>
  2. #include <list>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. struct comparer {
  7. int this_node;
  8.  
  9. comparer(int node) : this_node(node) {} // wtf? är det här ok?
  10.  
  11. bool operator()(int a, int b) {
  12. return (a+this_node > b);//(d(this_node,a) < d(this_node,b));
  13. }
  14. };
  15.  
  16. int main()
  17. {
  18. int foo[] = {55, 22, 33, 11, -11, -33};
  19. list<int> mylist (foo, foo+sizeof(foo)/sizeof(int));
  20.  
  21. mylist.sort(comparer(32));
  22.  
  23. for (list<int>::iterator it=mylist.begin(); it!=mylist.end(); ++it)
  24. cout << " " << *it;
  25. cout << endl;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment