skyouc
4 天以前 e26e6f4f980ea23b7b7bce6af3c1ea1b62285e7d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
 
public class ChineseMD5Util {
 
    public static List<Integer> getSelectedIndices(int[] arr) {
        List<Integer> indices = new ArrayList<>();
        int index = 0;
        int step = 3;
        while (index < arr.length) {
            indices.add(index);
            index += step;
            step = (step == 3) ? 1 : 3;
        }
        return indices;
    }
 
    public static Integer getNextSelectedValue(int[] arr, int inputIndex) {
        List<Integer> selectedIndices = getSelectedIndices(arr);
        int currentPos = selectedIndices.indexOf(inputIndex);
        if (currentPos != -1 && currentPos + 1 < selectedIndices.size()) {
            return arr[selectedIndices.get(currentPos + 1)];
        }
        return null; // 或按需处理
    }
 
    public static void main(String[] args) {
        int[] arr = {2, 5, 8, 10, 15, 20, 25, 30, 35, 40, 45, 50, 15, 40, 32, 48};
        System.out.println("输入 0,输出: " + getNextSelectedValue(arr, 0)); // 10
        System.out.println("输入 3,输出: " + getNextSelectedValue(arr, 3)); // 15
        System.out.println("输入 4,输出: " + getNextSelectedValue(arr, 4)); // 30
        System.out.println("输入 4,输出: " + getNextSelectedValue(arr, 5)); // 30
 
    }
}