Question #57383

rotate the word computer by 1 results is rCompute. If the input is 3, terCompu is the output.

Expert's answer

#include <iostream>
#include <string>

using namespace std;

int main() {
string s = "Computer";

int rot = 0;

cin >> rot;

for (int i = 0; i < s.length(); i++) {
cout << s[(i - rot) % s.length()];
}
return 0;
}

Result.
1
rCompute
LATEST TUTORIALS
APPROVED BY CLIENTS