为啥一个都过不了

P1307 [NOIP2011 普及组] 数字反转

_haruka @ 2024-01-14 21:14:50

#include <iostream>
using namespace std;
int main() {
    long long n,sum;
    cin>>n;
    while (n%10==0){
        n=n/10;
    }
    if(n<0){
        cout<<"-";
        n=-n;
    }
    while (n>=1){
        sum=sum*10+n%10;
        n=n/10;
    }
    cout<<sum;
}

by 瑾阳2012 @ 2024-01-16 10:21:54

考虑一下负数


|