我的代码:
#include <iostream>
#include <stack>
using namespace std;
stack<int> st;
int main()
{
int n;
bool f = 0;
cin >> n;
if (n == 0)
{
cout << 0;
return 0;
}
if (n < 0)
{
f = 1;
n = -n;
}
while (n != 0)
{
st.push(n % 10);
n /= 10;
}
while(!st.empty())
{
n *= 10;
n += st.top();
st.pop();
}
if (f == 1) cout << -n;
else cout << n;
}