#include using namespace std; void SwapChars(char & c1, char& c2){ char tmp = c1; c1 = c2; c2 = tmp; } void reverse(string S, int start_index, int end_index){ if (start_index < end_index){ SwapChars(S[start_index], S[end_index]); reverse(S, start_index+1, end_index-1); } } int main(int argc, char** argv){ if (argc!=2){ cout << "Parameters: STRING_TO_BE_REVERSED\n"; return 1; } string str = argv[1]; reverse(str,0,str.size()); cout << str << endl; }