[ create a new paste ] login | about

Link: http://codepad.org/zLZB3EZw    [ raw code | output | fork ]

hecomi - C++, pasted on Jun 23:
#include <list>
#include <iostream>
#include <functional>

using namespace std;

template <class T> struct _greater {
	bool operator() (const T& x, const T& y) const {
		return x>y;
	}
};

template <class T>
bool func_greater (const T &x, const T &y) {
	return (x >y);
}

int main()
{
	list<int> intlist;

	intlist.push_back(3);
	intlist.push_back(9);
	intlist.push_back(15);
	intlist.push_back(1);
	intlist.push_back(6);
	intlist.push_back(2);
	intlist.push_back(6);

	intlist.sort(&func_greater<int>);

	list<int>::iterator it = intlist.begin();
	while (it != intlist.end()) {
		cout << *it << endl;
		it++;
	}

	return 0;
}


Output:
1
2
3
4
5
6
7
15
9
6
6
3
2
1


Create a new paste based on this one


Comments: