首页 > 编程语言 > 详细

c++ 反转容器的元素顺序(reverse)

时间:2018-12-13 00:20:39      阅读:319      评论:0      收藏:0      [点我收藏+]

 

#include <vector>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
int main()
{
    vector<int> v{1,2,3};
    reverse(begin(v), end(v));//反转容器元素顺序 
    for(auto e : v) cout << e;
    cout << \n;
 
    int a[] = {4, 5, 6, 7};
    reverse(begin(a), end(a));//反转容器元素顺序 
    for(auto e : a) cout << e;
}

 

c++ 反转容器的元素顺序(reverse)

原文:https://www.cnblogs.com/sea-stream/p/10111736.html

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