C++ reverse函数的用法

mac2022-06-30  103

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

reverse函数用于反转在[first,last)范围内的顺序(包括first指向的元素,不包括last指向的元素),reverse函数无返回值

eg. 

string str="hello world , hi"; reverse(str.begin(),str.end());//str结果为 ih , dlrow olleh vector<int> v = {5,4,3,2,1}; reverse(v.begin(),v.end());//容器v的值变为1,2,3,4,5

转载于:https://www.cnblogs.com/yuanch2019/p/11591995.html

相关资源:逆向C (Reverse C )[中文版]
最新回复(0)