1. 火車票上*號打的是月,日,理論上的有最大366種組合;
2. 校驗碼是最後的一位,0-9及X,11個結果;
3. 那麼,通過火車票上的身份證號,可以得到33個左右真正的有效身份證號;
4. 如果你能知道對方的星座(嗯,大家不是經常曝自己是什麼星座麼),那麼,再將這30多個結果映射到12個星座中,最終可能性只有2-3個。。。
5. 結論:曬車票,一定要打碼
? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Geyunfei.CheckID
{
class Program
{
static int[] a = new int[] { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
static char[] b = new char[] { '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2' };
static int index = 0;
static void Main(string[] args)
{
System.Console.WriteLine("輸入火車票上的身份證號:");
String a = System.Console.ReadLine();
var year = int.Parse(a.Substring(6, 4));
var beginDate = new DateTime(year, 1, 1);
var chk = a.Substring(14);
int days = 365;
if (DateTime.IsLeapYear(year))
days++;
for(int i =0;i<days; i++)
{
var chkDate = beginDate.AddDays(i).ToString("MMdd");
var id = a.Substring(0, 10) + chkDate + chk;
CheckID(id);
}
}
private static void CheckID(string id)
{
int sum = 0;
for(int i = 0; i < 17; i++)
{
sum += int.Parse(id[i].ToString()) * a[i];
}
var chk = b[sum % 11];
if (chk == id[17])
{
index++;
Console.WriteLine(getAstro(int.Parse(id.Substring(10,2)),int.Parse(id.Substring(12,2)))+ index.ToString() +" "+id);
}
}
private static String getAstro(int month, int day)
{
String[] starArr = {"魔羯座","水瓶座", "雙魚座", "牡羊座",
"金牛座", "雙子座", "巨蟹座", "獅子座", "處女座", "天秤座", "天蠍座", "射手座" };
int[] DayArr = { 22, 20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22 }; // 兩個星座分割日
int index = month;
// 所查詢日期在分割日之前,索引-1,否則不變
if (day < DayArr[month - 1])
{
index = index - 1;
}
index = index % 12;
// 返回索引指向的星座string
return starArr[index];
}
}
}