Here's a brute-force C++ program to do it, assuming FixYa doesn't mangle the formatting. The last loop merely outputs the resulting list, since it makes no sense to just do all the work without showing the result.
====================
#include <iomanip>
#include <iostream>
#include <list>
#include <string>
using namespace std;
int main()
{
int brk, j;
list<char> lst;
string str;
cin >> str;
for (string::const_iterator i(str.begin()); i != str.end(); ++i)
lst.push_back(*i);
cin >> brk;
j = 0;
for (list<char>::iterator i(lst.begin()); j < brk; ++j) {
lst.push_back(*i);
lst.erase(lst.begin(), ++i);
}
for (list<char>::const_iterator i(lst.begin()); i != lst.end(); ++i)
cout << *i;
cout << endl;
return 0;
}
====================
77 views
Usually answered in minutes!
×