c中reverse函数用法?
reverse的功能是reverse(或reverse),主要用于字符串、数组和容器。头文件是#include<algorithm>
reverse函数,用于在[first,last](包括first指向的元素,不包括last指向的元素)范围内反转顺序。reverse函数没有返回值
例如
stringstr=“你好,你好”
reverse(str.开始(),结构端())//strresultisIH,dlrowolleh
vector<int>V={5,4,3,2,1}
reverse(V.begin(),V.end())//容器V的值变为1,2,3,4,5
~]//include“StdAfx。H“//VC6.0添加此行。#include<algorithm>#include<iostream>#include<string>使用namespacestdintmain(void){charSTR[]=“abcdefgh”strings=STRreverse(s.begin()2,s.begin())7)//与下面的句子相同//reverse(s.begin()2,s.end()-1)cout<<s<endlreturn0}
光影筑梦