Problem O: 逆序输出——C语言初学者百题大战之二十

#include<stdio.h>
int main()
{
    int a,b,c,d,e,n;
    scanf("%d",&n);
    a=n/10000;
    b=n%10000/1000;
    c=n%10000%1000/100;
    d=n%10000%1000%100/10;
    e=n%10000%1000%100%10;
    if(a!=0)
    printf("5\n%d%d%d%d%d\n",e,d,c,b,a);
    else if(a==0&&b!=0)
    printf("4\n%d%d%d%d\n",e,d,c,b);
    else if(a==0&&b==0&&c!=0)
    printf("3\n%d%d%d\n",e,d,c);
    else if(a==0&&b==0&&c==0&&d!=0)
    printf("2\n%d%d\n",e,d);    
    else if(a==0&&b==0&&c==0&&d==0&&e!=0)
    printf("1\n%d\n",e);
    return 0;
} 

猜你喜欢

转载自www.cnblogs.com/chenlong991223/p/9851904.html