如题: 
比如201  ---》 贰佰零壹圆整
200      ---》 贰佰圆整
2.11     ---》 贰圆壹角壹分整
2.01     ---》 贰圆壹分整自己写了段:
////////////////////////////////////////
CString CBottomView::ConvertToChineseNum(CString strNum)
{
CString strResult = CString(_T("")); if ( strNum.Find('.') == -1 )
strNum.Format("%s.",strNum); bool bNeedAdd = true;
for( int i=0,int j=strNum.Find('.'); i < strNum.GetLength(); i++)
{
bNeedAdd = true;
switch ( strNum[i] )
{
case '1':
strResult += CString(_T("壹"));
break;
case '2':
strResult += CString(_T("贰"));
break;
case '3':
strResult += CString(_T("叁"));
break;
case '4':
strResult += CString(_T("肆"));
break;
case '5':
strResult += CString(_T("伍"));
break;
case '6':
strResult += CString(_T("陆"));
break;
case '7':
strResult += CString(_T("柒"));
break;
case '8':
strResult += CString(_T("捌"));
break;
case '9':
strResult += CString(_T("玖"));
break;
case '0':
strResult += CString(_T("零"));
if ( j!=1 )
bNeedAdd = false;
break;
};
if ( bNeedAdd )
{ switch (j)
{
case -2:
strResult = strResult + CString(_T("分"));
break;
case -1:
strResult = strResult + CString(_T("角"));
break;
case 1:
strResult = strResult + CString(_T("圆"));
break;
case 2:
strResult = strResult + CString(_T("拾"));
break;
case 3:
strResult = strResult + CString(_T("佰"));
break;
case 4:
strResult = strResult + CString(_T("仟"));
break;
case 5:
strResult = strResult + CString(_T("万"));
break;
case 6:
strResult = strResult + CString(_T("拾"));
break;
case 7:
strResult = strResult + CString(_T("佰"));
break;
};
}
j--;
}
strResult += CString(_T("整"));
return strResult;
}/////////
开始以为很简单 
可是写到后面就不知道怎么搞了
主要是那个数字“0”有时候要 有时候不要
请教高手 谁有这方面的例子或者经验?

解决方案 »

  1.   

    整数和小数分开来处理
    整数4位4位处理
    0不加千百十这些 如果连续两个以上0只会有一个零就是说replace零...零with零
    最后加一个万,亿什么的
    eg:12345006
    1234 = 一千二百三十四 
    5006 = 五千零零六 =>五千零六
    1234因为是第二个四位就加一个万
    合成:一千二百三十四 万 五千零六01234560 => 零一百二十三 万 四千五百六十零 
    去头尾的零 =一百二十三 万 四千五百六十....
      

  2.   

    http://community.csdn.net/Expert/topic/2941/2941164.xml?temp=.9730951
    上面有类似的代码,只是好像少了零的判断,可有201只输出贰佰壹圆整.要加上零应该不难的.