public static void max(int x) { int temp = x; while (true) { int index = (int)Math.log10(temp); if (index < 0) { return; } int highDigit = (int) (Math.pow(10, index)); int highNumber = temp / highDigit; if (9 > highNumber) { x = x + highDigit * (9 - highNumber); System.out.println(x); return; } temp = temp - highDigit * highNumber; } }
给定一个正数,在只替换其中任意一个数字的情况下,使得这个数的值尽可能大(不考虑指数)
最新推荐文章于 2024-07-14 19:56:17 发布