fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main()
  5. {
  6. string a;
  7. cout << "请输入一个字符串:";
  8. cin >> a;
  9.  
  10. int len = a.length();
  11. for (int i = len - 1; i >= 0; i--)
  12. {
  13. cout << a[i];
  14. }
  15. cout << endl;
  16.  
  17. return 0;}
  18.  
  19.  
Success #stdin #stdout 0s 5284KB
stdin
45
stdout
请输入一个字符串:54