Java算法小笔记

获得数字的位数

    private int getFigure(int x){
        int val = 10, figure = 1;
        while( ( x / val ) > 0 ){
            figure++;
            x /= val;
        }
        //System.out.println("该数字有【" + figure + "】位");
        return figure;
    }

你可能感兴趣的:(Java算法小笔记)