如何用c程序编写一个输入任意一个整数,将其逆序输出,例如输入1234, 输出4321。

如何用c程序编写一个输入任意一个整数,将其逆序输出,例如输入1234, 输出4321。要代码

#include <stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    if(n == 0) printf("0\n");
    else
    {    
        if(n<0)
        {
            printf("-");
            n=-n;
        }
        while(n)
        {
            printf("%d",n%10);
            n/=10;
        }
    }
    return 0;
}
温馨提示:答案为网友推荐,仅供参考