码迷,mamicode.com
首页 > 编程语言 > 详细

C++ STL partial_sort

时间:2019-06-12 21:25:37      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:==   turn   str   pause   ace   bsp   shuff   push   random   

#include <iostream>
#include <deque>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
  deque<int> deq1;
  deque<int>::iterator deq_iter1;

  for (int k=0;k<15;k++)
  {
    deq1.push_back(rand());
  }

  for (deq_iter1 = deq1.begin();deq_iter1 != deq1.end();++deq_iter1)
  {
    cout << *deq_iter1 << " ";
  }
  cout << endl;
  cout << "----------------------------------" << endl;

  partial_sort(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;

  //random_shuffle(deq1.begin(), deq1.end());

 

  system("pause");
  return 0;
}

==========================================================

41 18467 6334 26500 19169 15724 11478 29358 26962 24464 5705 28145 23281 16827 9961
----------------------------------
41 5705 6334 9961 11478 26500 19169 29358 26962 24464 18467 28145 23281 16827 15724
----------------------------------
请按任意键继续. . .

 

C++ STL partial_sort

标签:==   turn   str   pause   ace   bsp   shuff   push   random   

原文地址:https://www.cnblogs.com/herd/p/11012716.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!