user-0 提问: 还是不会正整数读法 直接求码！！！

回复:
user: user-0

user: user-1
content: #include <stdio.h> #include <string.h> char hznum[100]; char hzunit[15][3]={"","十","百","千","万","十","百","千","亿","十","百","千","万","十","百"}; char hzdigit[10][3]={"零","一","二","三","四","五","六","七","八","九"}; char numstr[20]; char *ReadNumByHZ(double v) {     char *p,*d;     int u,i;      sprintf(numstr,"%.15lg",v);     printf("%s\n",numstr);     if ('-'==numstr[0]) {         sprintf(hznum,"不支持读负数");         return hznum;     }     p=strchr(numstr,'e');     if (NULL!=p) {         sprintf(hznum,"不支持读太大或太小的数");         return hznum;     }     d=NULL;     p=strchr(numstr,'.');     if (NULL!=p) {         p[0]=0;         d=p+1;     }     u=strlen(numstr);     hznum[0]=0;     for (i=0;i<u;i++) {         if ('0'==numstr[i] && 0!=((u-1-i)%4)) {             sprintf(hznum,"%s%s",hznum,hzdigit[numstr[i]-'0']);         } else {             sprintf(hznum,"%s%s%s",hznum,hzdigit[numstr[i]-'0'],hzunit[u-1-i]);         }     }     printf("%s\n",hznum);     u=strlen(hznum);     for (i=0;i<u;i+=2) {         if (0==strncmp(hznum+i,"零零",4)) {//多个连续的“零”改成一个“零”             memmove(hznum+i,hznum+i+2,u-i-2+1);             i-=2;             u-=2;         }     }     printf("%s\n",hznum);     if (0==strcmp(hznum+u-2,"零")) {//末尾“零”去掉         hznum[u-2]=0;         u-=2;     }     printf("%s\n",hznum);     for (i=0;i<u;i+=2) {         if (0==strncmp(hznum+i,"零万",4) || 0==strncmp(hznum+i,"零亿",4)) {//“万”“亿”前是“零”去掉             memmove(hznum+i,hznum+i+2,u-i-2+1);             u-=2;         }     }     printf("%s\n",hznum);     if (NULL!=d) {         sprintf(hznum,"%s点",hznum);         i=0;         while (1) {             if (0==d[i]) break;             sprintf(hznum,"%s%s",hznum,hzdigit[d[i]-'0']);             i++;         }     }     printf("%s\n",hznum);     return hznum; } void main() {     printf("\n%s\n",ReadNumByHZ(130040600090.012)); } //130040600090.012 //一千三百零零亿四千零六十零万零零九十零 //一千三百零亿四千零六十零万零九十零 //一千三百零亿四千零六十零万零九十 //一千三百亿四千零六十万零九十 //一千三百亿四千零六十万零九十点零一二 // //一千三百亿四千零六十万零九十点零一二  #include <afx.h> #include <stdio.h> CString ChineseCapitalMoney(double Num) {     CString szChMoney,szNum;     int iLen, iNum, iAddZero=0;     TCHAR* hzUnit[18]={_T("分"),_T("角"),_T("元"),_T("拾"),_T("佰"),_T("仟"),_T("万"),_T("拾"),_T("佰"),_T("仟"),_T("亿"),_T("拾"),_T("佰"),_T("仟"),_T("万"),_T("拾"),_T("佰"),_T("仟")};     TCHAR* hzNum[10]={_T("零"),_T("壹"),_T("贰"),_T("叁"),_T("肆"),_T("伍"),_T("陆"),_T("柒"),_T("捌"),_T("玖")};     if (-0.01<Num && Num<0.01) return _T("零元整");     szNum.Format(_T("%18.0f"), Num*100); // 最小到分     szNum.TrimLeft();     iLen=szNum.GetLength();     if(iLen>15 || iLen==0 || Num<0) return _T(""); // 数据错误返回      for(int i=0;i<iLen;i++) {         iNum=_ttoi((LPCTSTR)szNum.Mid(i,1));         if (iNum==0) {             iAddZero++;         } else {             if (iAddZero>0) szChMoney+=_T("零");             szChMoney+=hzNum[iNum];             iAddZero=0;         }         if (iNum!=0 || iLen-i==3 || iLen-i==11 || ((iLen-i+1)%8==0 && iAddZero<4)) szChMoney+=hzUnit[iLen-i-1];     }     if (szNum.Right(2)==_T("00")) szChMoney+=_T("整"); // 没有角和分     return szChMoney; } void main() {     double d;     CString s;      d=-1.0            ;printf("%16.2f %s\n",d,ChineseCapitalMoney(d));     d=0.0             ;printf("%16.2f %s\n",d,ChineseCapitalMoney(d));     d=1234501234567.89;printf("%16.2f %s\n",d,ChineseCapitalMoney(d));     d=1000000000000.01;printf("%16.2f %s\n",d,ChineseCapitalMoney(d));     d=1000000000001.00;printf("%16.2f %s\n",d,ChineseCapitalMoney(d));     d= 130040600090.01;printf("%16.2f %s\n",d,ChineseCapitalMoney(d)); } //           -1.00 //            0.00 零元整 //1234501234567.89 壹万贰仟叁佰肆拾伍亿零壹佰贰拾叁万肆仟伍佰陆拾柒元捌角玖分 //1000000000000.01 壹万亿元零壹分 //1000000000001.00 壹万亿零壹元整 // 130040600090.01 壹仟叁佰亿零肆仟零陆拾万零玖拾元零壹分

user: user-0
content: 1楼同学能不能给几行例子？

user: user-2
content: 可以给你提供思路：1，把这个整数转化成字符数组，然后对每一位的数字进行读取，用到switch case。 2,，计算出每位 的数字，可以通过取余的方法，当然可以用你想的到的方法。