哪位来看看出啥问题了。。。。
#include<stdio.h>void main()
{
void trans(float n);
float n;
scanf("%f",&n);
int p;
p=(int)n; //为啥这里不能把float转化为int类型的,该怎么改?我这个程序想把输入转化为英语。小数点后面程序不用!!就是求助这里为啥不能转化!!!//
trans(p);
}
void trans(int n)
{
int t[10],i=0,j,m,p;
char a[][15]={"","One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine ","Ten ","eleven ","Twelve ","Thirteen ","Fourteen ","Fifteen ","Sixteen ","Seventeen ","Eighteen ","Nineteen "};
char b[][15]={"","","Twenty ","Thirty ","Forty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninety ","hundred "};
char c[][10]={"","thousand ","million ","billion "};
while(n>0)
{
t[i]=n%1000;
n=n/1000;
i++;
}
if(n==1000000000)
printf("%s%s",a[1],c[3]);
for(j=i-1;j>=0;j--)
{
if(t[j]>=100)
{
m=t[j]/100;
t[j]=t[j]%100;
printf("%s%sand",a[m],b[10]);
}
if(t[j]>=20)
{
m=t[j]/10;
t[j]=t[j]%10;
printf("%s",b[m]);
}
if(t[j]>0)
printf("%s",a[t[j]]);
if(j>0)
{
printf("%s",c[j]);
}
}
printf("\n");
}