70分求解释

P1307 [NOIP2011 普及组] 数字反转

wenzhe @ 2017-04-17 11:38:28

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    int m,n,i,j,k,l,count=1;
    cin>>m;
    if(m>=0)
        {
        k=m;
        l=k;}
    else
        {k=(-1)*m;l=k;cout<<"-";}    
    for(i=1;k>10;k/=10)
        count++;
    const int a=count;
    int array[a];
    for(j=0;j<a;j++)    
        {
            if(l>=10)
                {array[j]=l%10;
                l/=10;}
            else
                array[j]=l;        
        }
    for(i=0;i<a;i++)
        if(array[i]!=0)
         cout<<array[i];
    return 0;         
}

by tumult_2 @ 2017-04-18 20:13:06

前导零


|