Java
public class Ic { public static String get18Ic(String identityCard) { String retId = ""; String id17 = ""; int sum = 0; int y = 0; int[] wf = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 }; String[] cc = { "1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2" }; if (identityCard.length() != 15) { return identityCard; } id17 = identityCard.substring(0, 6) + "19" + identityCard.substring(6); for (int i = 0; i < 17; i++) { sum = sum + Integer.valueOf(id17.substring(i, i + 1)) * wf[i]; } y = sum % 11; retId = id17 + cc[y]; return retId; } public static void main(String[] args) { // 例子 System.out.println(get18Ic("")); // 结果 } }
讯享网

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/26282.html