方法1:

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string n;
    cin >> n;
    for (int i = n.size() - 1; i != -1; i--) {
        cout << n[i];
    }
}

方法2:

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    string n;
    cin >> n;
    reverse(n.begin(), n.end());
    cout << n;
}