#11405: 不好意思~因為自己電腦測會通過~不知道這邊一直測不過的原因在哪~求高手解惑


freewade (wade)

學校 : 不指定學校
編號 : 59535
來源 : [223.140.211.45]
最後登入時間 :
2018-03-12 08:40:48
a020. 身分證檢驗 | From: [223.140.18.42] | 發表日期 : 2016-10-04 10:29


import java.util.*;

public class ChkID {


public static void main(String[] args) {

Scanner scn=new Scanner(System.in);
String ckID;
while(scn.hasNext()){
ckID=scn.nextLine();
splitID(ckID);
}
}
public static void splitID(String strID) //將身分證字號分解放入陣列處理;
{
String CTStr;
int CTNum=0;
int[] intIDarr = new int[10];
for (int i = 0; i < 10; i++){
if (i == 0){
CTStr=strID.substring(0,1);
switch (CTStr){
case "A":
CTNum = 10;
break;
case "B":
CTNum = 11;
break;
case "C":
CTNum = 12;
break;
case "D":
CTNum = 13;
break;
case "E":
CTNum = 14;
break;
case "F":
CTNum = 15;
break;
case "G":
CTNum = 16;
break;
case "H":
CTNum = 17;
break;
case "J":
CTNum = 18;
break;
case "K":
CTNum = 19;
break;
case "L":
CTNum = 20;
break;
case "M":
CTNum = 21;
break;
case "N":
CTNum = 22;
break;
case "P":
CTNum = 23;
break;
case "Q":
CTNum = 24;
break;
case "R":
CTNum = 25;
break;
case "S":
CTNum = 26;
break;
case "T":
CTNum = 27;
break;
case "U":
CTNum = 28;
break;
case "V":
CTNum = 29;
break;
case "X":
CTNum = 30;
break;
case "Y":
CTNum = 31;
break;
case "W":
CTNum = 32;
break;
case "Z":
CTNum = 33;
break;
case "I":
CTNum = 34;
break;
}
intIDarr[0] = CTNum;
//intIDarr[0] = getCTNum(strID.substring(0,1));
//System.out.print("intIDarr[0]= "+intIDarr[0]+" \n");
}else{
intIDarr[i] = Integer.parseInt(strID.substring(i,i+1));
//System.out.print("intIDarr["+i+"]= "+intIDarr[i]+" ");
}
}
chkNewID(intIDarr);
}
public static void chkNewID(int[] arrID)
{
int chkIDarr,checker;
int CTcode=arrID[0]/10;
chkIDarr = CTcode + (arrID[0]%10) * 9 + arrID[1] * 8 + arrID[2] * 7 + arrID[3] * 6 + arrID[4] * 5 + arrID[5] * 4 + arrID[6] * 3 + arrID[7] * 2 + arrID[8] * 1 + arrID[9] ;
//System.out.println(chkIDarr);
checker = chkIDarr % 10;

if(checker==0){
System.out.println("real");
}else{
System.out.println("fake");
}
}
}

 
ZeroJudge Forum