C语言中,怎么将一个数反向输出?

如题所述

代码: #include<stdio.h>
void main()
{
long x,temp=0;
printf("请输入一个数:\n");
scanf("%ld",&x);
while(x!=0)
{
temp=temp*10+x%10;
x=x/10;
}
printf("这个数的方向输出的结果是:%ld\n",temp);
}
图:
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-07-17
#include<stdio.h>
int main()
{
int n,m;
scanf("%d",&n);
m=0;
while(n)
{
m=m*10+n%10;
n=n/10;
}
printf("%d\n",m);
return 0;
}
相似回答