public class MyInteger { // System.out.println(NumberAt(998156452, 4)); //返回 6
public static int NumberAt(Integer num, int unit) { if (unit == 1) return num % 10; int after = 1; while (--unit > 0) after *= 10; int rest = num % after; return ((num - rest) / after) % 10; } public static int NumberLength(Integer num) { int len = 1, sum = 10; while (num >= sum) { sum *= 10; len++; } return len; } }
标签:10,java,数字,int,sum,after,num,拆分,unit From: https://www.cnblogs.com/laremehpe/p/17567831.html