template <class ForwardIterator, class OutputIterator> OutputIterator rotate_copy( ForwardIterator xFirst, ForwardIterator xMiddle, ForwardIterator xLast, OutputIterator xDest );
#include <algorithm>
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
using namespace std;
// Create two vector instances
vector<char> qV1;
qV1.push_back('X');
qV1.push_back('o');
qV1.push_back('a');
qV1.push_back('X');
qV1.push_back('.');
qV1.push_back('n');
qV1.push_back('e');
qV1.push_back('t');
vector<char> qV2(12, '-');
vector<char>::iterator qIter;
// Output the vectors
cout << "Original V1: ";
for (qIter = qV1.begin(); qIter != qV1.end(); ++qIter) {
cout << *qIter;
}
cout << endl;
cout << "Original V2: ";
for (qIter = qV2.begin(); qIter != qV2.end(); ++qIter) {
cout << *qIter;
}
cout << endl;
// Copy the first six rotated entries of v1 into the third entry of v2
vector<char>::iterator qEndOfCopyIter;
qEndOfCopyIter = rotate_copy(qV1.begin(), qV1.begin()+4, qV1.begin()+6, qV2.begin()+2);
// Output the result vector
cout << "Resulting V2: ";
for (qIter = qV2.begin(); qIter != qV2.end(); ++qIter) {
cout << *qIter;
}
cout << endl;
// Keep the window open
cin.get();
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.