#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <functional>
#include <iterator>ios
using namespace std;spa
int main()
{
deque<int> deq1;
deque<int>::iterator deq_iter1;element
for (int k=0;k<16;k++)
{
deq1.push_back(rand());
}it
for (deq_iter1 = deq1.begin();deq_iter1 != deq1.end();++deq_iter1)
{
cout << *deq_iter1 << " ";
}
cout << endl;
cout << "------------------------------"<<endl;io
nth_element(deq1.begin(), deq1.begin() + 5, deq1.end());
for (deq_iter1 = deq1.begin(); deq_iter1 != deq1.end(); ++deq_iter1)
{
cout << *deq_iter1 << " ";
}
cout << endl;
cout << "------------------------------" << endl;function
copy(deq1.begin(), deq1.begin() + 5,ostream_iterator<int>(cout," "));
cout << endl;
cout << "------------------------------" << endl;stream
nth_element(deq1.begin(), deq1.end() - 5, deq1.end());
copy(deq1.end() - 5,deq1.end(), ostream_iterator<int>(cout, " "));
cout << endl;
cout << "------------------------------" << endl;copy
nth_element(deq1.begin(), deq1.begin() + 5,deq1.end(), greater<int>());
for (deq_iter1 = deq1.begin(); deq_iter1 != deq1.end(); ++deq_iter1)
{
cout << *deq_iter1 << " ";
}
cout << endl;
cout << "------------------------------" << endl;co
system("pause");
return 0;
}push
==================================
41 18467 6334 26500 19169 15724 11478 29358 26962 24464 5705 28145 23281 16827 9961 491------------------------------41 491 5705 6334 9961 11478 15724 16827 18467 19169 23281 24464 26500 26962 28145 29358------------------------------41 491 5705 6334 9961------------------------------24464 26500 26962 28145 29358------------------------------29358 28145 26962 26500 24464 23281 19169 18467 16827 15724 11478 9961 6334 5705 491 41------------------------------請按任意鍵繼續. . .