<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 冰封的愛 閱讀(1102) 評論(1)  編輯  收藏 所屬分類: 常用工具

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

    常用鏈接

    留言簿(3)

    隨筆檔案

    文章分類

    文章檔案

    相冊

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲综合久久久久久中文字幕| 亚洲色偷偷狠狠综合网| 亚洲色偷偷av男人的天堂| xxxx日本在线播放免费不卡| 国产zzjjzzjj视频全免费| 国产精品无码亚洲精品2021| 亚洲 综合 国产 欧洲 丝袜| 猫咪免费人成在线网站| 亚洲av无码不卡私人影院| 免费中文字幕视频| 亚洲国产中文v高清在线观看| 一级毛片高清免费播放| 亚洲精品老司机在线观看| 久久免费99精品国产自在现线| 亚洲综合在线另类色区奇米| baoyu777永久免费视频| 久久夜色精品国产噜噜噜亚洲AV| 最好看最新的中文字幕免费| 亚洲人成网网址在线看| 日本免费人成黄页网观看视频| 猫咪免费观看人成网站在线| 国产亚洲精品福利在线无卡一| 久久国产乱子精品免费女| 亚洲欧洲久久精品| 国产国产人免费视频成69大陆| 窝窝影视午夜看片免费| 久久精品视频亚洲| 最新免费jlzzjlzz在线播放| 黄色一级视频免费| 久久亚洲精品成人AV| 特级淫片国产免费高清视频| 两个人的视频www免费| 亚洲最大免费视频网| 无码国产亚洲日韩国精品视频一区二区三区| igao激情在线视频免费| 亚洲成人免费电影| 亚洲欧洲中文日韩久久AV乱码| 亚洲黄色免费在线观看| 永久免费无码日韩视频| 亚洲欧洲日本精品| 国产亚洲人成A在线V网站|