首页 > 编程语言 > 详细

C++ STL partial_sort_copy greater

时间:2019-06-12 21:48:14      阅读:84      评论:0      收藏:0      [点我收藏+]

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

using namespace std;

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

  vector<int> vec1(15);

  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_copy(deq1.begin(), deq1.end(), vec1.begin(), vec1.end(),greater<int>());
  vector<int>::iterator vec_iter1;

  for (vec_iter1 = vec1.begin();vec_iter1 != vec1.end();++vec_iter1)
  {
    cout << *vec_iter1 << " ";
  }
  cout << endl;

 

  system("pause");
  return 0;
}

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

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

 

C++ STL partial_sort_copy greater

原文:https://www.cnblogs.com/herd/p/11012748.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!