编程序实现如下功能:从键盘输入一个包含小数的小写金额(整数部分不超过7位),将其转换为汉字大写金额,最后输出结果。
求大佬改正#include<stdio.h>
main(void)
{
int i,j=0,k,s;
int w[9];
double a,b,c;
scanf("%lf",&a);
a=a+0.001;
s=a;
k=(a-s)*100;
if((a-s)>0)
{
w[1]=k/10;
w[0]=k%10;
}
else
{
w[1]=0;
w[0]=0;
}
while(s!=0)
{
w[2+j]=s%10;
s=s/10;
j++;
}
for(i=9;i>=j+2;i–)
w[i]=0;
for(i=j+1;i>=0;i–)
{
switch(w[i])
{
case 1:printf(“壹”);break;
case 2:printf(“贰”);break;
case 3:printf(“叁”);break;
case 4:printf(“肆”);break;
case 5:printf(“伍”);break;
case 6:printf(“陆”);break;
case 7:printf(“柒”);break;
case 8:printf(“捌”);break;
case 9:printf(“玖”);break;
case 0:printf(“零”);break;
}
switch(i+1)
{
case 1:printf(“分”);break;
case 2:printf(“角”);break;
case 3:printf(“元”);break;
case 4:printf(“拾”);break;
case 5:printf(“佰”);break;
case 6:printf(“仟”);break;
case 7:printf(“万”);break;
case 8:printf(“拾”);break;
case 9:printf(“佰”);break;
}
}
printf("\n");
return 0;
}