2016-10-19 回答
#include
#include
void main()
{
double x,i=10000000;
int j=0;
unsigned int quotient,remainder;
bool beginflag=0,zeroflag=0;
cout<
cin>>x;
while (x>=100000000)
{
if (j>=2)
{
cout<
return;
}
cout<
cout<
cin>>x;
j++;
}
if (x<=0)
{
cout<
return;
}
x=floor(x*100 +0.5)/100; //小数点后2位四舍五入
while (i>0.001)
{
if (i>0.9)
quotient=(unsigned int)floor(x/i);
else
{
if (i>=0.099)
quotient=(unsigned int)floor(x*10);
else
quotient=(unsigned int)floor(x*100);
}
remainder=quotient%10;
if (remainder!=0)
beginflag=1;
if ((zeroflag==1) && (beginflag==1) && (i>1000) && (remainder>0))
cout<
switch (remainder) //输出大写数字
{
case 0:
break;
case 1:
cout<
break;
case 2:
cout<
break;
case 3:
cout<
break;
case 4:
cout<
break;
case 5:
cout<
break;
case 6:
cout<
break;
case 7:
cout<
break;
case 8:
cout<
break;
case 9:
cout<
break;
}
if (remainder>0)
zeroflag=0;
else if (beginflag==1)
zeroflag=1;
if (beginflag==1) //输出单位
{
if ((i==10000000) && (remainder>0))
cout<
if ((i==1000000) && (remainder>0))
cout<
if ((i==100000) && (remainder>0))
cout<
if (i==10000)
cout<
if ((i==1000) && (remainder>0))
cout<
if ((i==100) && (remainder>0))
cout<
if ((i==10) && (remainder>0))
cout<
if (i==1)
cout<
if ((i>=0.09) && (i<1) && (remainder>0))
cout<
if ((i>=0.009) && (i<0.1) && (remainder>0))
cout<
}
i=i/10;
}
cout<
}
//测试结果: