<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 14,  comments - 37,  trackbacks - 0

    采用了遞歸的方法

      1package src;
      2/** *//**
      3 * 
      4 * @author Mr.Yang
      6 */

      7public class Numeric {
      8
      9    /** *//**
     10     * @param args
     11     */

     12    public static void main(String[] args) {
     13        System.out.println(getChinese(2147483648l,0));
     14    }

     15    /** *//**
     16     * 獲得阿拉伯數字對應的中文
     17     * 最大只支持到9千9百九十九億9千9百九十九萬9千9百九十九
     18     * @param number 要轉換的數字
     19     * @param depth 遞歸深度,使用時候直接給0即可
     20     * @return 數字的中文描述
     21     */

     22    public static String getChinese(long number,int depth){
     23        if(depth<0)
     24            depth = 0;
     25        String chinese = "";
     26        String src = number+"";
     27        if(src.charAt(src.length()-1)=='l' || src.charAt(src.length()-1)=='L' )
     28        {
     29            src = src.substring(0, src.length()-1);
     30        }

     31        System.out.println(src);
     32        
     33        if(src.length()>4)
     34            chinese = getChinese(Integer.parseInt(src.substring(0, src.length()-4)),depth+1)+
     35                getChinese(Integer.parseInt(src.substring(src.length()-4, src.length())),depth-1);
     36        else{
     37            char prv = 0;
     38            for(int i=0;i<src.length();i++){
     39                switch(src.charAt(i)){
     40                case '0':
     41                    if(prv != '0')
     42                    chinese = chinese+"";
     43                    break;
     44                case '1':
     45                    chinese = chinese+"";
     46                    break;
     47                case '2':
     48                    chinese = chinese+"";
     49                    break;
     50                case '3':
     51                    chinese = chinese+"";
     52                    break;
     53                case '4':
     54                    chinese = chinese+"";
     55                    break;
     56                case '5':
     57                    chinese = chinese+"";
     58                    break;
     59                case '6':
     60                    chinese = chinese+"";
     61                    break;
     62                case '7':
     63                    chinese = chinese+"";
     64                    break;
     65                case '8':
     66                    chinese = chinese+"";
     67                    break;
     68                case '9':
     69                    chinese = chinese+"";
     70                    break;
     71                }

     72                prv = src.charAt(i);
     73                
     74                switch(src.length()-1-i){
     75                case 1://
     76                    if(prv != '0')
     77                    chinese = chinese + "";
     78                    break;
     79                case 2://
     80                    if(prv != '0')
     81                    chinese = chinese + "";
     82                    break;
     83                case 3://
     84                    if(prv != '0')
     85                    chinese = chinese + "";
     86                    break;
     87                
     88                }

     89            }

     90        }

     91        while(chinese.length()>0 && chinese.lastIndexOf("")==chinese.length()-1)
     92            chinese = chinese.substring(0,chinese.length()-1);
     93        if(depth == 1)
     94            chinese += "";
     95        if(depth == 2)
     96            chinese += "";
     97        
     98        return chinese;
     99    }

    100
    101}

    102
    posted on 2007-07-09 15:46 冰封的愛 閱讀(1103) 評論(1)  編輯  收藏 所屬分類: 常用工具

    FeedBack:
    # re: 阿拉伯數字轉換為中文大寫漢字
    2009-01-30 18:31 | 往往
    我是我  回復  更多評論
      
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(3)

    隨筆檔案

    文章分類

    文章檔案

    相冊

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲av成人一区二区三区在线观看 | 亚洲娇小性色xxxx| 日韩中文无码有码免费视频| 青青视频免费在线| 亚洲第一中文字幕| 免费看片免费播放| 国产偷伦视频免费观看| 亚洲中文无码亚洲人成影院| 中文字幕在亚洲第一在线 | 免费看美女让人桶尿口| fc2成年免费共享视频网站| 亚洲黄色在线电影| 亚洲第一网站男人都懂| 最近免费最新高清中文字幕韩国| 亚洲暴爽av人人爽日日碰| 亚洲高清专区日韩精品| 蜜臀91精品国产免费观看| 你是我的城池营垒免费看| 亚洲第一永久在线观看| 免费A级毛片无码久久版| 1000部禁片黄的免费看| 无码日韩人妻AV一区免费l| 亚洲国产成人手机在线电影bd| 久久激情亚洲精品无码?V| 成人午夜免费福利| 欧洲精品99毛片免费高清观看| 日韩色视频一区二区三区亚洲| 亚洲视频在线播放| 亚洲国产精品综合久久网络| 91免费播放人人爽人人快乐| 一级特黄录像免费播放肥| 亚洲乱码无人区卡1卡2卡3| 久久久久久久亚洲Av无码| 亚洲综合色在线观看亚洲| 成年丰满熟妇午夜免费视频| 99精品在线免费观看| 黄色视屏在线免费播放| 国产精品亚洲综合天堂夜夜| 亚洲人成毛片线播放| 久久精品国产亚洲AV无码麻豆| 国产成人亚洲影院在线观看|