改后程序如下:
#include
int main()
{
float num;
int a,b,c,d,e,f,g,h,i,j;
printf("请输入一个金额如345.78\n");
scanf("%f",&num);
a=(int)num/100;
b=(int)(num-a*100)/50;
c=(int)(num-a*100-b*50)/10;
d=(int)(num-a*100-b*50-c*10)/5;
e=(int)(num-a*100-b*50-c*10-d*5)/2;
f=(int)(num-a*100-b*50-c*10-d*5-e*2)/1;
g=(int)((num-a*100-b*50-c*10-d*5-e*2-f*1)*10)/5;
h=(int)((num-a*100-b*50-c*10-d*5-e*2-f*1-g*0.5)*10);
i=(int)((num-a*100-b*50-c*10-d*5-e*2-f*1-g*0.5-h*0.1)*20)/5;
j=(int)((num-a*100-b*50-c*10-d*5-e*2-f*1-g*0.5-h*0.1-i*0.05)*100);
printf("100元、50元、10元、5元、2元、1元、5角、1角、5分、1分各有%d,%d,%d,%d,%d,%d,%d,%d,%d,%d张",a,b,c,d,e,f,g,h,i,j);
return 0;
}