c++中reverse函数实现vector变量的翻转
最后发布:2019-10-16 20:40:49
首发:2019-10-16 20:40:49
<div id="article_content" class="article_content clearfix">
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-211130ba7a.css">
<div id="content_views" class="markdown_views prism-atom-one-dark">
<!-- flowchart 箭头图标 勿删 -->
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path>
</svg>
<p>reverse(v.begin(),v.end())</p>
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int> a;
a.push_back(1);
a.push_back(2);
a.push_back(3);
reverse(a.begin(),a.end());
for(int i=0;i<a.size();i++){
cout<<a[i]<<endl;
}
return 0;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
</div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-60ecaf1f42.css" rel="stylesheet">
<div></div>
<div class="person-messagebox">
<div class="left-message"><a href="https://blog.csdn.net/qq_31672701">
<img src="https://profile.csdnimg.cn/A/A/D/3_qq_31672701" class="avatar_pic" username="qq_31672701">
</a></div>
<div class="middle-message">
<div class="title"><span class="tit "><a href="https://blog.csdn.net/qq_31672701" data-report-click="{"mod":"popu_379","ab":"new"}" target="_blank">Crystal_Coding</a></span>
<!-- 等级,level -->
<img class="identity-icon" src="https://csdnimg.cn/identity/blog6.png"> </div>
<div class="text"><span>原创文章 341</span><span>获赞 15</span><span>访问量 7万+</span></div>
</div>
<div class="right-message">
<a class="btn btn-sm bt-button personal-watch" data-report-click="{"mod":"popu_379","ab":"new"}">关注</a>
<a href="https://im.csdn.net/im/main.html?userName=qq_31672701" target="_blank" class="btn btn-sm bt-button personal-letter">私信
</a>
</div>
</div>
</div>
</article>