求教:为什么我着个程序计算不了5位数?
代码如下:#include<stdio.h>
main()
{
int num,fannum,i,n,m;
printf("This program reverses the digits in an interger.\n");
printf("Enter a positive integer:");
scanf("%d",&num);
n=num;
i=0;
m=1;
while (n>0) {
n/=10;
i++;
m*=10;
}
fannum=0;
m/=10;
while (num>0) {
n=num%10;
fannum+=n*m;
m/=10;
num/=10;
i--;
}
printf("The reversed number is %d\n",fannum);
}
在TC2.0下运行,输入5位数就会输出负数,搞不明白啊。