#include "stdio.h"
int main (void)
{
long number;
unsigned int a,b,c,d,e,leap=0;
clrscr();
printf("qing shu ru yi ge bu duo yu 5 wei de zheng shu:\n");
scanf("%ld",&number);
if(number>99999)
leap=1;
a=number/10000;
b=(number-10000*a)/1000;
c=(number-10000*a-1000*b)/100;
d=(number-10000*a-1000*b-100*c)/10;
e= number-10000*a-1000*b-100*c-10*d;
if(leap==0)
{
if(a!=0)
{
printf("zhe shi yi ge wu wei shu:\n");
printf("ni xu shu chu shi:%u%u%u%u%u",e,d,c,b,a);
}
else if(b!=0)
{
printf("zhe shi si wei shu:\n");
printf("ni xu shu chu shi:%u%u%u%u",e,d,c,b);
}
else if(c!=0)
{
printf("zhe shi yi ge san wei shu:\n");
printf("ni xu shu chu shi:%u%u%u",e,d,c);
}
else if(d!=0)
{
printf("zhe shi yi ge liang wei shu:\n");
printf("ni xu shu chu shi:%u%u",e,d);
}
else
{
printf("zhe shi yi ge yi wei shu:\n");
printf("ni xu shu chu shi:%u",e);
}
}
else
printf("shu ru cuo wu!");
getch();
}
运行结果是对的。
----------------解决方案--------------------------------------------------------
你定义的number为浮点型,而scanf函数中用的是%d,所以输出肯定错的。
哦 这样啊~~又粗心了!!谢谢ls ----------------解决方案--------------------------------------------------------