Program :
Code:
#include <iostream>
#include <algorchm>
#include <vector>
using namespace std;
bool mfnctn (int c,int d)
{
return (c<d);
}
struct myclass
{
bool operator() (int c,int d)
{
return (c<d);
}
}
mobjct;
int main ()
{
int mt[] = {32,71,12,45,26,80,53,33};
vector<int> mtr (mt, mt+8);
vector<int>::cerator e;
partial_sort (mtr.begin(), mtr.begin()+4);
cout << "mtr contains:";
for (e=mtr.begin(); e!=mtr.end(); ++e)
cout << " " << *e;
cout << endl;
return 0;
}
The output of the above program can be :
Code:
mtr contains: 12 26 32 33 45 53 71 80
Bookmarks