我这么牛逼的代码哪里错了?!!

P1307 [NOIP2011 普及组] 数字反转

zzchemistry @ 2015-08-23 09:04:48

#include<stdio.h>
int main()
{
    int n;
    int ge,shi,bai,qian,wan,shiwan,baiwan,qianwan,yi,shiyi;
    int nge,nshi,nbai,nqian,nwan,nshiwan,nbaiwan,nqianwan,nyi,nshiyi;
    scanf("%d",n);
    if(n >= 0 && n <= 1000000000)
    {
        shiyi=n/1000000000;
        yi=n%1000000000/100000000;
        qianwan=n%1000000000%100000000/10000000;
        baiwan=n%1000000000%100000000%10000000/1000000;
        shiwan=n%1000000000%100000000%10000000%1000000/100000;
        wan=n%1000000000%100000000%10000000%1000000%100000/10000;
        qian=n%1000000000%100000000%10000000%1000000%100000%10000/1000;
        bai=n%1000000000%100000000%10000000%1000000%100000%10000%1000/100;
        shi=n%1000000000%100000000%10000000%1000000%100000%10000%1000%100/10;
        ge=n%1000000000%100000000%10000000%1000000%100000%10000%1000%100%10;
            if(ge != 0)
            printf("%d",ge*1000000000+shi*100000000+bai*10000000+qian*1000000+wan*100000+shiwan*10000+baiwan*1000+qianwan*100+yi*10+shiyi);
            if(ge == 0 && shi != 0)
            printf("%d",shi*100000000+bai*10000000+qian*1000000+wan*100000+shiwan*10000+baiwan*1000+qianwan*100+yi*10+shiyi);
            if(ge == 0 && shi == 0 && bai != 0)
            printf("%d",bai*10000000+qian*1000000+wan*100000+shiwan*10000+baiwan*1000+qianwan*100+yi*10+shiyi);
            if(ge == 0 && shi == 0 && bai == 0 && qian != 0)
            printf("%d",qian*1000000+wan*100000+shiwan*10000+baiwan*1000+qianwan*100+yi*10+shiyi);
            if(ge == 0 && shi == 0 && bai == 0 && qian == 0 && wan != 0) 
            printf("%d",wan*100000+shiwan*10000+baiwan*1000+qianwan*100+yi*10+shiyi);
            if(ge == 0 && shi == 0 && bai == 0 && qian == 0 && wan == 0 && shiwan != 0)
            printf("%d",shiwan*10000+baiwan*1000+qianwan*100+yi*10+shiyi);
            if(ge == 0 && shi == 0 && bai == 0 && qian == 0 && wan == 0 && shiwan == 0 && baiwan != 0)
            printf("%d",baiwan*1000+qianwan*100+yi*10+shiyi);
            if(ge == 0 && shi == 0 && bai == 0 && qian == 0 && wan == 0 && shiwan == 0 && baiwan == 0 && qianwan != 0)
            printf("%d",qianwan*100+yi*10+shiyi);
            if(ge == 0 && shi == 0 && bai == 0 && qian == 0 && wan == 0 && shiwan == 0 && baiwan == 0 && qianwan == 0 && yi != 0)
            printf("%d",yi*10+shiyi);
            if(ge == 0 && shi == 0 && bai == 0 && qian == 0 && wan == 0 && shiwan == 0 && baiwan == 0 && qianwan == 0 && yi == 0)
            printf("%d",shiyi);
    }
    if(n >= -1000000000 && n < 0)
    {
        nshiyi=-n/1000000000;
        nyi=-n%1000000000/100000000;
        nqianwan=-n%1000000000%100000000/10000000;
        nbaiwan=-n%1000000000%100000000%10000000/1000000;
        nshiwan=-n%1000000000%100000000%10000000%1000000/100000;
        nwan=-n%1000000000%100000000%10000000%1000000%100000/10000;
        nqian=-n%1000000000%100000000%10000000%1000000%100000%10000/1000;
        nbai=-n%1000000000%100000000%10000000%1000000%100000%10000%1000/100;
        nshi=-n%1000000000%100000000%10000000%1000000%100000%10000%1000%100/10;
        nge=-n%1000000000%100000000%10000000%1000000%100000%10000%1000%100%10;
            if(nge != 0)
            printf("%d",-(nge*1000000000+nshi*100000000+nbai*10000000+nqian*1000000+nwan*100000+nshiwan*10000+nbaiwan*1000+nqianwan*100+nyi*10+nshiyi));
            if(nge == 0 && nshi != 0)
            printf("%d",-(nshi*100000000+nbai*10000000+nqian*1000000+nwan*100000+nshiwan*10000+nbaiwan*1000+nqianwan*100+nyi*10+nshiyi));
            if(nge == 0 && nshi == 0 && nbai != 0)
            printf("%d",-(nbai*10000000+nqian*1000000+nwan*100000+nshiwan*10000+nbaiwan*1000+nqianwan*100+nyi*10+nshiyi));
            if(nge == 0 && nshi == 0 && nbai == 0 && nqian != 0)
            printf("%d",-(nqian*1000000+nwan*100000+nshiwan*10000+nbaiwan*1000+nqianwan*100+nyi*10+nshiyi));
            if(nge == 0 && nshi == 0 && nbai == 0 && nqian == 0 && nwan != 0) 
            printf("%d",-(nwan*100000+nshiwan*10000+nbaiwan*1000+nqianwan*100+nyi*10+nshiyi));
            if(nge == 0 && nshi == 0 && nbai == 0 && nqian == 0 && nwan == 0 && nshiwan != 0)
            printf("%d",-(nshiwan*10000+nbaiwan*1000+nqianwan*100+nyi*10+nshiyi));
            if(nge == 0 && nshi == 0 && nbai == 0 && nqian == 0 && nwan == 0 && nshiwan == 0 && nbaiwan != 0)
            printf("%d",-(nbaiwan*1000+nqianwan*100+nyi*10+nshiyi));
            if(nge == 0 && nshi == 0 && nbai == 0 && nqian == 0 && nwan == 0 && nshiwan == 0 && nbaiwan == 0 && nqianwan != 0)
            printf("%d",-(nqianwan*100+nyi*10+nshiyi));
            if(nge == 0 && nshi == 0 && nbai == 0 && nqian == 0 && nwan == 0 && nshiwan == 0 && nbaiwan == 0 && nqianwan == 0 && nyi != 0)
printf("%d",-(yi*10+shiy…

by MifuneShioriko @ 2015-08-23 12:03:21

orz楼主你这么牛x我也是醉了

数字反转直接把字符串末尾的0去掉然后倒着输出就行了,至于么你这样,我也是醉了


by 罗小米 @ 2015-08-23 13:59:48

楼主牛逼,我的话会以字符串读入


by SpYder_Hacker @ 2015-08-23 14:22:09

scanf("%d",n);

你说呢?


by Return_0 @ 2015-08-23 15:52:08

楼主牛啊


by 儒雅随和_mata川 @ 2015-08-23 18:31:45

醉的不清啊。


by nonprocess @ 2015-08-23 18:32:43

@[url=/space/show?uid=8670]zzchemistry[/url] 同三楼,楼主你连读入都写不好,


by RUNRUN @ 2015-08-23 18:40:10

@[url=/space/show?uid=8670]zzchemistry[/url] 你连读入都错了,就不说什么了


by zzchemistry @ 2015-08-23 21:33:00

scanf发之前就改过了,照错


by M_seа @ 2015-08-26 20:52:41

楼主,你这程序


by TLE_King @ 2015-08-27 11:16:48

楼主,我醉了


| 下一页