Created
December 24, 2014 13:39
-
-
Save anonymous/0ed951c9abeb51b4b9d5 to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ 程序实例 publicclassId18 { int[] weight={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}; //十七位数字本体码权重 char[] validate={ '1','0','X','9','8','7','6','5','4','3','2'}; //mod11,对应校验码字符值 publicchargetValidateCode(String id17){ intsum=0; intmode=0; for(inti=0;i<id17.length();i++){ sum=sum+Integer.parseInt(String.valueOf(id17.charAt(i)))*weight[i]; } mode=sum%11; returnvalidate[mode]; } publicstaticvoidmain(String[] args){ 16Id18 test=newId18(); System.out.println("该身份证验证码:"+test.getValidateCode("14230219700101101")); //该身份证校验码:3 } }