a020.
身分證檢驗
| From: [111.253.196.215] |
發表日期
:
2014-01-12 10:49
package test;
import java.util.Scanner;
public class Mj {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
{
while (cin.hasNext()) {
String a = cin.nextLine();
String[] b = a.split("");
char[] c = b[1].toCharArray();
if (c[0] == 'A')
b[1] = "10";
if (c[0] == 'B')
b[1] = "11";
if (c[0] == 'C')
b[1] = "12";
if (c[0] == 'D')
b[1] = "13";
if (c[0] == 'E')
b[1] = "14";
if (c[0] == 'F')
b[1] = "15";
if (c[0] == 'G')
b[1] = "16";
if (c[0] == 'H')
b[1] = "17";
if (c[0] == 'I')
b[1] = "34";
if (c[0] == 'J')
b[1] = "18";
if (c[0] == 'K')
b[1] = "19";
if (c[0] == 'L')
b[1] = "20";
if (c[0] == 'M')
b[1] = "21";
if (c[0] == 'N')
b[1] = "22";
if (c[0] == 'O')
b[1] = "35";
if (c[0] == 'P')
b[1] = "23";
if (c[0] == 'Q')
b[1] = "24";
if (c[0] == 'R')
b[1] = "25";
if (c[0] == 'S')
b[1] = "26";
if (c[0] == 'T')
b[1] = "27";
if (c[0] == 'U')
b[1] = "28";
if (c[0] == 'V')
b[1] = "29";
if (c[0] == 'W')
b[1] = "32";
if (c[0] == 'X')
b[1] = "30";
if (c[0] == 'Y')
b[1] = "31";
if (c[0] == 'Z')
b[1] = "33";
int[] cd = new int[10];
for (int i = 0; i < 10; i++)
cd[i] = Integer.parseInt(b[i + 1]);
int test, e, f;
e = cd[0] / 10;
f = cd[0] % 10;
test = e + f * 9 + cd[9];
for (int i = 0; i < 9; i++)
test = test + (cd[i + 1] * (8 - i));
test = test % 10;
if (test == 0)
System.out.println("real");
else
System.out.println("fake");
}
}
}
}