C语言输出除了最高位的数字

#include 

unsigned long re(unsigned long n);

int main(){
    unsigned long n;
    scanf("%lu",&n);
    printf("%lu",re(n));
}

unsigned long re(unsigned long n){
    unsigned long s,r=0;
    while(n/10!=0){
        s = s*10 + n%10;
        n = n/10;
    }
    while(s!=0){
        r = r*10 + s%10;
        s = s/10;
    }
    return r;
}

我采用反转再反转的方法输出除最高位的数字.

你可能感兴趣的:(c语言,算法,c++)