反向输出一个五位数
描述
反向输出一个五位数
输入
一个五位数n。
输出
反向输出n。
输入样例 1
12345
输出样例 1
54321
方法一:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
string number;
cin >> number;
reverse(number.begin(), number.end());
cout << number << endl;
return 0;
}
方法二:
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
while (n > 0) {
cout << n % 10;
n /= 10;
}
cout << endl;
return 0;
}