深夜腦洞,寫了一個可以推算火車票社會安全號碼碼的小程式

來源:互聯網
上載者:User

標籤:

1. 火車票上*號打的是月,日,理論上的有最大366種組合;

2. 校正碼是最後的一位,0-9及X,11個結果;

3. 那麼,通過火車票上的社會安全號碼,可以得到33個左右真正的有效社會安全號碼;

4. 如果你能知道對方的星座(嗯,大家不是經常曝自己是什麼星座麼),那麼,再將這30多個結果映射到12個星座中,最終可能性只有2-3個。。。 

5. 結論:曬車票,一定要打碼

using 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];        }    }}

  

深夜腦洞,寫了一個可以推算火車票社會安全號碼碼的小程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.