sorting in c++

Tags:

#include
#include // less_than
#include
#include
#include

using namespace std;

int main()
{
int nums[] = { 3, 2, 1, 4, 2,
5, 6, 9, 7, 5};
vector vi(nums, nums + 10);

sort(vi.begin(), vi.end(), less());
copy(vi.begin(), vi.end(), ostream_iterator(cout, ” “));
cout << endl; sort(vi.begin(), vi.end(), greater());
copy(vi.begin(), vi.end(), ostream_iterator(cout, ” “));
cout << endl; return EXIT_SUCCESS; } [/code] less의 헤더는 functional 이다.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *