zoukankan      html  css  js  c++  java
  • 把数字翻译成字符串

    public static int numOfIntToString(int number)
        {
            if (number < 0)
            {
                return -1;
            }
            if (number > 0 && number <= 9)
            {
                return 1;
            }
            // 转换成相应的字符串
            String strNum = number + "";
            int end = strNum.length() - 1;
            int[] count = new int[strNum.length()];
            for (int i = end; i >= 0; i--)
            {
                count[i] = numOfIntToStringCor(strNum, i, end, count);
            }
            return count[0];

        }

        public static int numOfIntToStringCor(String strNum, int begin, int end,
                int[] count)
        {
            int res = 0;
            if (begin == end)
            {
                return 1;
            }
            if (end >= strNum.length())
            {
                return -1;
            }
            Integer temp = new Integer(strNum.substring(begin, begin + 2));
            if (temp >= 10 && temp <= 25)
            {
                if (begin + 2 <= end)
                {
                    return count[begin + 1] + count[begin + 2];
                }
            }
            res = count[begin + 1];
            return res;
        }

  • 相关阅读:
    vb.net 数组参与SQL语句的查询范例
    JQUERY范例
    DOS批处理释义
    GridVIew单元格合并
    [无关] 胡言乱语3
    [数据] ZZ 数据分析这点事
    [ZZ] Big Data 开源工具
    [python] ZZ 时间相关
    python 获取时间代码
    javascript基础之我见(1)深度理解原型链
  • 原文地址:https://www.cnblogs.com/qingtianBKY/p/8310865.html
Copyright © 2011-2022 走看看