题解 | #数字颠倒#
数字颠倒
https://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe
方法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; }