根据前17位算出第18位身份证号

public static void main(String[] args){
    String code ="41068319901011097";
    int[] _jqyz = new int[]{7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
String[] z = new String[]{"1","0","X","9","8","7","6","5","4","3","2"};
    int sum = 0;
    for(int i=0;i<_jqyz.length;i++){
        sum +=  _jqyz[i]*Integer.parseInt(code.charAt(i)+"");
}
    System.out.print("最后一位是:"+(z[sum%11]));

}

猜你喜欢

转载自bigseven.iteye.com/blog/2301551