why

P1307 [NOIP2011 普及组] 数字反转

chishen @ 2023-08-18 15:57:50

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n,f;
    cin>>n;
    if(n<0){
        cout<<'-';
    } 
    while(n!=0)
    {
        if(n<0) n=fabs(n);
        f=n%10;
        n=n/10;
        if(f==0)
        {
            continue;
        }
        cout<<f;
    }
    return 0;
}

by Hilte @ 2023-08-18 16:02:15

@chishen 这删的0不只是前导0,而是全部0


by unhappysheep @ 2023-08-18 16:06:36

@chishen 6


by chishen @ 2023-08-18 16:07:04

@Hilte 感谢,最近再刷题,脑子有点懵


|