zoukankan      html  css  js  c++  java
  • c++ 容器切片反转次序(不拷贝到新容器)

    // rotate algorithm example
    #include <iostream>     // cout
    #include <algorithm>    // rotate
    #include <vector>       // vector
    using namespace std;
    int main () {
      vector<int> myvector;
    
      // set some values:
      for (int i=1; i<10; ++i) myvector.push_back(i); // 1 2 3 4 5 6 7 8 9
    
      rotate(myvector.begin(),myvector.begin()+3,myvector.end());
                                                      // 4 5 6 7 8 9 1 2 3
      // print out content:
      cout << "myvector contains:";
      for (vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
        cout << ' ' << *it;
      cout << '
    ';
    
      return 0;
    }

    输出

    myvector contains: 4 5 6 7 8 9 1 2 3
  • 相关阅读:
    VS自带的诊断工具
    Electron学习
    PC跨*台
    .NET调试学习
    Mac使用
    SSL/TLS
    UKey学习
    授权机制OAuth、JWT
    代理服务器
    .NET相关源码查找
  • 原文地址:https://www.cnblogs.com/sea-stream/p/10891762.html
Copyright © 2011-2022 走看看