繁花如伊
您可以[0, high - low]通过删除low您的值将您的值放入间隔中,然后将您想要的数字添加到它,取总和的模数,最后加low回来回到范围内[low, high]public static void main(String[] args) { int low = 65, high = 90; System.out.println(addWithinInterval(85, 10, low, high));}private static int addWithinInterval(int value, int add, int low, int high) { return (value - low + add) % (high - low + 1) + low;}