逆转
1.reverse()
reverse(ivec.begin(),ivec.end()); //123456转换成654321
2.reverse_copy()
reverse_copy(ivec.begin()+1,ivec.end()-1,ostream_iterator<int>(cout," "));
//123456789 转换成8765432
旋转
1.rotate()
rotate(ivec.begin(),ivec.begin()+1,ivec.end()); //12345转换成23451
rotate(ivec.begin(),find(ivec.begin(),ivec.end(),4),ivec.end()); //12345转换成45123
2.rotate_copy()
rotate_copy(iset.begin(),iset.begin()+1,iset.end(),ostream_iterator<int>(cout," "));
// 12345转换成23451
rotate_copy(iset.begin(),iset.find(4),iset.end(),ostream_iterator<int>(cout," ")); //set中有find的成员函数,把找到的4作为头进行旋转
//12345转换成45123
网友评论