最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

reverse函数 ——反转容器内容

互联网 admin 1浏览 0评论

reverse函数 ——反转容器内容

reverse函数功能是逆序(或反转),多用于字符串、数组、容器。头文件是#include

#include<bits/stdc++.h>using namespace std;int main()
{string s;//反转字符串cin>>s;reverse(s.begin(), s.end());cout<<s;
}
#include<bits/stdc++.h>using namespace std;int main()
{vector<int> v = {1,2,3,4,5};//反转容器reverse(v.begin(), v.end());vector<int>::iterator it;for(it = v.begin(); it != v.end(); it++){cout<<*it<<" ";}
}

reverse函数 ——反转容器内容

reverse函数功能是逆序(或反转),多用于字符串、数组、容器。头文件是#include

#include<bits/stdc++.h>using namespace std;int main()
{string s;//反转字符串cin>>s;reverse(s.begin(), s.end());cout<<s;
}
#include<bits/stdc++.h>using namespace std;int main()
{vector<int> v = {1,2,3,4,5};//反转容器reverse(v.begin(), v.end());vector<int>::iterator it;for(it = v.begin(); it != v.end(); it++){cout<<*it<<" ";}
}

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论