演示类属算法rotate

类属算法rotate对区间内的元素进行循环移位操作,如: rotate(first,middle,last) 将区间[first,last)内的元素循环左移middle-first个位置

#include <iostream>
#include
<cassert>
#include
<algorithm>
#include
<vector>
#include
<string>
using namespace std;

int main()
{
cout
<<"Illustrating the generic rotate algorithm."<<endl;
string s("Software Engineering ");
vector
<char> vector1(s.begin(),s.end());

rotate(vector1.begin(),vector1.begin()
+9,vector1.end());
assert(
string(vector1.begin(),vector1.end())==string("Engineering Software "));
cout
<<" --- OK."<<endl;
return 0;
}
原文地址:https://www.cnblogs.com/djcsch2001/p/2059184.html