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

#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;
}

猜你喜欢

转载自www.cnblogs.com/sea-stream/p/10111736.html
今日推荐