ساننىڭ خەنزۇچە چوڭ يېزىلىشىنى چىقىش

ئاپتور admin ئېلان قىلىنغان ۋاقتى 2013-12-05 13:29 يازما تۈرلىرى c# يازما باھاسى دىۋان ئىگەللەيمەن ئوقۇلۇشى
پوچتا بانكىسىغا پۇل قويۇش ئۈچۈن بارغىنىمدا دائىم پۇلنىڭ چوڭ يېزىلىشنى تەلەپ قىلىدۇ ،شۇنىڭ بىلەن توردىن ئىزدىنىش ئارقىلىق ساننىڭ خەنزۇچە چوڭ يېزىلىشنى چىقىرىپ بېلىدىغان پىروگراممىدىن بىرنى .......
 public string UpMoney(decimal D_Mstr_theMoney)
       {
           string G_str_Money = "零壹贰叁肆伍陆柒捌玖"; //0-9所对应的汉字
           string G_str_MoneyString = "万仟佰拾亿仟佰拾万仟佰拾元角分";   //数字位所对应的汉字
           string G_str_Timoney = "";   //从原D_Mstr_theMoney值中取出的值
           string G_str_NumberString = "";  //数字的字符串形式
           string G_str_UpMoney = ""; //人民币大写金额形式
           int i;         //循环变量
           int j;         //D_Mstr_theMoney的值乘以100的字符串长度
           string G_ch_Chine = "";  //数字的汉语读法
           string G_ch_Chineses = ""; //数字位的汉字读法
           int G_int_ZeroCount = 0;//用来计算连续的零值是几个
           int G_int_G_int_temp; //从原D_Mstr_theMoney值中取出的值
           D_Mstr_theMoney = Math.Round(Math.Abs(D_Mstr_theMoney), 2);//将D_Mstr_theMoney取绝对值并四舍五入取2位小数
           G_str_NumberString = ((long)(D_Mstr_theMoney * 100)).ToString(); //将D_Mstr_theMoney乘100并转换成字符串形式
           j = G_str_NumberString.Length;//找出最高位
           if (j > 15) { return "溢出"; }
           G_str_MoneyString = G_str_MoneyString.Substring(15 - j); //取出对应位数的G_str_MoneyString的值。如:200.55,j为5所以G_str_MoneyString=佰拾元角分
           //循环取出每一位需要转换的值
           for (i = 0; i < j; i++)
           {
               G_str_Timoney = G_str_NumberString.Substring(i, 1); //取出需转换的某一位的值
               G_int_G_int_temp = Convert.ToInt32(G_str_Timoney); //转换为数字
               if (i != (j - 3) && i != (j - 7) && i != (j - 11) && i != (j - 15))
               {
                   //当所取位数不为元、万、亿、万亿上的数字时
                   if (G_str_Timoney == "0")
                   {
                       G_ch_Chine = "";
                       G_ch_Chineses = "";
                       G_int_ZeroCount = G_int_ZeroCount + 1;
                   }
                   else
                   {
                       if (G_str_Timoney != "0" && G_int_ZeroCount != 0)
                       {
                           G_ch_Chine = "零" + G_str_Money.Substring(G_int_G_int_temp * 1, 1);
                           G_ch_Chineses = G_str_MoneyString.Substring(i, 1);
                           G_int_ZeroCount = 0;
                       }
                       else
                       {
                           G_ch_Chine = G_str_Money.Substring(G_int_G_int_temp * 1, 1);
                           G_ch_Chineses = G_str_MoneyString.Substring(i, 1);
                           G_int_ZeroCount = 0;
                       }
                   }
               }
               else
               {
                   //该位是万亿,亿,万,元位等关键位
                   if (G_str_Timoney != "0" && G_int_ZeroCount != 0)
                   {
                       G_ch_Chine = "零" + G_str_Money.Substring(G_int_G_int_temp * 1, 1);
                       G_ch_Chineses = G_str_MoneyString.Substring(i, 1);
                       G_int_ZeroCount = 0;
                   }
                   else
                   {
                       if (G_str_Timoney != "0" && G_int_ZeroCount == 0)
                       {
                           G_ch_Chine = G_str_Money.Substring(G_int_G_int_temp * 1, 1);
                           G_ch_Chineses = G_str_MoneyString.Substring(i, 1);
                           G_int_ZeroCount = 0;
                       }
                       else
                       {
                           if (G_str_Timoney == "0" && G_int_ZeroCount >= 3)
                           {
                               G_ch_Chine = "";
                               G_ch_Chineses = "";
                               G_int_ZeroCount = G_int_ZeroCount + 1;
                           }
                           else
                           {
                               if (j >= 11)
                               {
                                   G_ch_Chine = "";
                                   G_int_ZeroCount = G_int_ZeroCount + 1;
                               }
                               else
                               {
                                   G_ch_Chine = "";
                                   G_ch_Chineses = G_str_MoneyString.Substring(i, 1);
                                   G_int_ZeroCount = G_int_ZeroCount + 1;
                               }
                           }
                       }
                   }
               }
               if (i == (j - 11) || i == (j - 3))
               {
                   //如果该位是亿位或元位,则必须写上
                   G_ch_Chineses = G_str_MoneyString.Substring(i, 1);
               }
               G_str_UpMoney = G_str_UpMoney + G_ch_Chine + G_ch_Chineses;

               if (i == j - 1 && G_str_Timoney == "0")
               {
                   //最后一位(分)为0时,加上“整”
                   G_str_UpMoney = G_str_UpMoney + '整';
               }
           }
           if (D_Mstr_theMoney == 0)
           {
               G_str_UpMoney = "零元整";
           }
           return G_str_UpMoney;
       }

http://qaran.6te.net/?p=131 | قارخان:(permalink) مۇقىم ئۇلانما

مەزكۇر يازما ئاپتورى: admin| ۋاقت:2013-يىل12-ئاينىڭ05-كۈنى| يازما تۈرى:c# ، سىز باھا يوللىيالايسىز، ھەمدە يازما ئەسلى مەنزىلى ۋە ئاپتورنى ساقلاپ قالغان ئاساستا، ئۆزىڭىزنىڭ توربېتى ياكى تۇرايىڭىزغا ھەمقەدەم قىلالايسىز.
ئىجادىي يازمىلارنى ئىشلەتكەندە مەنبەنى ئەسكەرتىپ قويۇڭ: ساننىڭ خەنزۇچە چوڭ يېزىلىشىنى چىقىش | قارخان

باھا يېزىش

تېزلەتمە كونۇپكا:Ctrl+Enter
Free Web Hosting