80分,C++

P1307 [NOIP2011 普及组] 数字反转

qumo_04 @ 2024-10-27 14:07:01

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    if (n < 0)n=abs(n),cout<<"-";
    if (n%10==0)n/=10;
    if (n ==0)cout<<n;
    while(n !=0)
    {
        int num=n%10;
        cout << num;
        n/=10;
    }
    return 0;
}

|