大家好,欢迎来到IT知识分享网。
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://haidsoft.com/105208.html