zoukankan      html  css  js  c++  java
  • C++ STL partial_sort

    #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
    ----------------------------------
    请按任意键继续. . .

  • 相关阅读:
    黑色边影,
    拉伸的代码,
    一定是selection的原因啊,要不然呢,
    status bar的差别,
    黄色,
    域名错了,
    node=day4
    PS切片
    移动端插件IScroll.js
    移动web资源概论
  • 原文地址:https://www.cnblogs.com/herd/p/11012716.html
Copyright © 2011-2022 走看看