题解 | 反向输出一个四位数
反向输出一个四位数
https://www.nowcoder.com/practice/1f7c1d67446e4361bf4af67c08e0b8b0
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
// int n;
// cin >> n;
// int res=0;
// for(int i = 0;i < 4;i++){
// res = res*10 + n % 10;
// n /= 10;
// }
// printf("%04d\n",res);
// 数值不如字符串优雅,题目要求输入整数,实际上 当做输入字符串即可
string s;
cin >> s;
reverse(s.begin(),s.end());
cout << s << endl;
}
// 64 位输出请用 printf("%lld")
查看15道真题和解析