//String 1234...递增 求str[m]     //1-9  10-99 100-999 .....     //位数 1*9 2*90 3*900 .....     public static Character getM(int m){         int count = 1;         int flag = 9;         int res = m + 1; //下标从0开始 所以加1         while(res > 0){             res -= count * flag;             count ++;             flag *= 10;         }         count --;         flag /= 10;         res += count * flag;         int shang = (res - 1) / count;         int yu = (res - 1) % count;         res = (count - 1) * (flag / 10) + 1 + shang;         String str = String.valueOf(res);         return str.charAt(yu);     }
点赞 2

相关推荐

牛客网
牛客企业服务