C++萌新 求各位大神指正

P1307 [NOIP2011 普及组] 数字反转

sandyzikun @ 2017-09-14 16:06:41

#include <cstdio>
int main() 
{
    int m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m,p,n;
    scanf ("%d",m);
    p=m;
    m1=p/1000000000;
    p-=m1*1000000000;
    m2=p/100000000;
    p-=m2*100000000;
    m3=p/10000000;
    p-=m3*10000000;
    m4=p/1000000;
    p-=m4*1000000;
    m5=p/100000;
    p-=m5*100000;
    m6=p/10000;
    p-=m6*10000;
    m7=p/1000;
    p-=m7*1000;
    m8=p/100;
    p-=m8*100;
    m9=p/10;
    p-=m9*10;
    m10=p;
    n=m1+m2*10+m3*100+m4*1000+m5*10000+m6*100000+m7*1000000+m8*10000000+m9*100000000+m10*1000000000;
    if (m1==0)
    {
        n=n/10;
        if (m2==0)
        {
            n=n/10;
            if (m3==0)
            {
                n=n/10;
                if (m4==0)
                {
                    n=n/10;
                    if (m5==0)
                    {
                        n=n/10;
                        if (m6==0)
                        {
                            n=n/10;
                            if (m7==0)
                            {
                                n=n/10;
                                if (m8==0)
                                {
                                    n=n/10;
                                    if (m9==0)
                                    {
                                        n=n/10;
                                           if (m10=0)
                                           {
                                            n=n/10;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    printf ("%d",n);
    return 0;
}

by 夏真诚 @ 2017-09-21 20:46:56

大佬厉害


by 縱橫依舊 @ 2017-09-23 10:41:13

你是没救了


by 无欢 @ 2017-09-29 12:35:24

er...,你scanf不用加‘&’吗?


|