day22

作者: 今生何求惟你 | 来源:发表于2018-07-02 12:29 被阅读1次

    题目:给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。

    程序

    #include <stdio.h>

    int main(void)

    {

    int a,b,c,d,e,i;

    long s;

    printf("Please enter a number:");

    scanf("%d",&s);

    a=s/10000;

    b=s/1000%10;

    c=s/100%10;

    d=s/10%10;

    e=s%10;

    if(a!=0)

    printf("They are 5\n%d %d %d %d %d\n",e,d,c,b,a);

    else if(b!=0)

    printf("They are 4\n%d %d %d %d\n",e,d,c,b);

    else if(c!=0)

    printf("They are 3\n%d %d %d\n",e,d,c);

    else if(d!=0)

    printf("They are 2\n%d %d\n",e,d);

    else if(e!=0)

    printf("They are 1\n%d\n",e);

    return 0;

    }

    输出样例

    day22

    相关文章

      网友评论

        本文标题:day22

        本文链接:https://www.haomeiwen.com/subject/nxakuftx.html