正序整数的分解

#include 
int main(int argc, const char * argv[]) {
    //1234/1000->1
    //1234%1000->234
    //1000/10->100
    //234/100->2
    //234%100->34
    //100/10->10
    //34/10->3
    //34%10->4
    //10/10->1
    //4/10->0
    int mask=1;
    int t;
    int x;
    scanf("%d",&x);
    t=x;
    while (t>9) {
        t/=10;
        mask*=10;
    }
    do {
       int  d=x/mask;
        printf("%d",d);
        if (mask>9) {
            printf(" ");
        }
        x%=mask;
        mask/=10;
    } while (mask>0);
    printf("\n");
    return 0;
}

你可能感兴趣的:(c语言,xcode)