题解 | #字符逆序#
字符逆序
https://www.nowcoder.com/practice/cc57022cb4194697ac30bcb566aeb47b
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { string strInput; getline(cin,strInput); vector<char> vecChar; for (char chVal : strInput) { vecChar.push_back(chVal); } reverse(vecChar.begin(), vecChar.end()); string strOutput = ""; for (size_t i = 0; i < vecChar.size(); i++) { strOutput += vecChar[i]; } cout << strOutput << endl; } // 64 位输出请用 printf("%lld")