+ 3
Extra-terrestrials Help
I need help with the extra-terrestrials challenge. I'm able to reverse the string, but all my test cases fail. Am I missing something? https://code.sololearn.com/cTUQK8TC4DkZ/?ref=app
3 Answers
+ 6
change to int i = userInput.size()-1;
+ 4
Reivin Dedstinguer Ahhh, Thank you. I'm an idiot lol
+ 3
FYI, there is a reverse function in the Non-standard header;
#include <bits/stdc++.h>
And similarly in the header;
#include <algorithm>
Either, does an in place reversal of the string by passing in the begin and end iterators of the object.
reverse(userInput.begin(), userInput.end());
cout << userInput;
http://cplusplus.com/reference/algorithm/reverse/