?
What will be the output of the following C++ code?
What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool myfunction (int i,int j)
{
return (i < j);
}
int main ()
{
int myints[] = {9, 8, 7, 6};
vector<int> myvector (myints, myints + 4);
partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end());
partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end(),
myfunction);
for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool myfunction (int i,int j)
{
return (i < j);
}
int main ()
{
int myints[] = {9, 8, 7, 6};
vector<int> myvector (myints, myints + 4);
partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end());
partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end(),
myfunction);
for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}
Join the Discussion
Login to post a comment or share your explanation.
Login