<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     * 獲得阿拉伯?dāng)?shù)字對(duì)應(yīng)的中文
     17     * 最大只支持到9千9百九十九億9千9百九十九萬(wàn)9千9百九十九
     18     * @param number 要轉(zhuǎn)換的數(shù)字
     19     * @param depth 遞歸深度,使用時(shí)候直接給0即可
     20     * @return 數(shù)字的中文描述
     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 += "萬(wàn)";
     95        if(depth == 2)
     96            chinese += "";
     97        
     98        return chinese;
     99    }

    100
    101}

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

    FeedBack:
    # re: 阿拉伯?dāng)?shù)字轉(zhuǎn)換為中文大寫漢字
    2009-01-30 18:31 | 往往
    我是我  回復(fù)  更多評(píng)論
      
    <2025年7月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    常用鏈接

    留言簿(3)

    隨筆檔案

    文章分類

    文章檔案

    相冊(cè)

    搜索

    •  

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 午夜免费福利网站| 中文字幕日韩亚洲| 免费播放春色aⅴ视频| 亚洲中文字幕无码久久精品1| 亚洲资源在线视频| 亚洲欧美成人一区二区三区| 99精品全国免费观看视频..| 成年男女免费视频网站| 久久精品国产精品亚洲艾草网| 亚洲AV无码一区二区三区久久精品| a级特黄毛片免费观看| 亚洲一区AV无码少妇电影☆| 99久久婷婷国产综合亚洲| 中文在线观看国语高清免费| 性做久久久久免费观看| 亚洲激情黄色小说| 免费成人在线视频观看| 亚洲国产综合久久天堂| 亚洲成_人网站图片| 四虎国产成人永久精品免费| av无码东京热亚洲男人的天堂 | 四虎永久免费网站免费观看| 中文字幕亚洲综合久久2| 啦啦啦完整版免费视频在线观看 | 亚洲乱码在线观看| 日本成人免费在线| 一级午夜免费视频| 四虎国产精品免费视| sss日本免费完整版在线观看| 国产精品免费电影| 亚洲日韩中文字幕一区| 国产一区二区三区免费视频| 亚洲一区二区三区免费| 99亚洲精品高清一二区| 99久9在线|免费| 亚洲av无码精品网站| 成人免费视频77777| 亚洲狠狠成人综合网| 亚洲国产婷婷综合在线精品| 一区二区三区无码视频免费福利 | 最近中文字幕电影大全免费版|