身份证第18位计算

public class 身份证 {
	public static void main(String[] args) {
		int[] 十七位系数 = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
		String 身份证前17位 = "42080120001212406";
		long sum = 0;
		for (int i = 0; i < 身份证前17位.length(); i++) {
			int n = Integer.parseInt(身份证前17位.charAt(i) + "");
			sum += n * 十七位系数[i];
		}
		long index = sum % 11;
		String 第18位 = "10X98765432";
		char c18 = 第18位.charAt((int) index);
		System.out.println(c18);
	}
}
原文地址:https://www.cnblogs.com/tigerlion/p/12496667.html