c语言中从标准输入上读入整数正整数n,使用递归函数逆序输出n的各位数字。例如123输出321,1

00输出21。

#include <stdio.h>
int main()
{
    int a, t;
    scanf ("%d", &a);
    t = 0;
    while (a){
        t= t*10+a%10;
        a/=10;
    }
    printf("%d\n", t);
    return 0;
}

追问

可以用正规一点的格式吗?这样有点乱

追答#include <stdio.h>
int main()
{
    int a, t = 0, g;
    scanf ("%d", &a);
    while (a!=0)
    {
        g = a%10;
        t= t*10+g;
        a/=10;
    }
    printf("%d\n", t);
    return 0;
}

这也乱,我也是醉了

追问

谢了

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-11-30
直接用函数就可以了,用什么递归追问

作业规定的

相似回答