Late-night brain hole, wrote a small program that can calculate the ID number of a train ticket

Source: Internet
Author: User

1. The train ticket * number is the month, the day, theoretically has the largest 366 kinds of combinations;

2. Check code is the last one, 0-9 and x,11 results;

3. Then, through the ID number on the train ticket, you can get 33 or so real valid ID number;

4. If you can know each other's constellation (well, people do not often expose themselves to what is the constellation), then, then the 30 more results mapped to 12 constellations, the final probability is only 2-3 ...

5. Conclusion: You must make a code for the Sun ticket

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 ("Enter the ID number on the train ticket:");            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, Ten) + Chkdate + chk;            Checkid (ID); }} private static void Checkid (string id) {int sum = 0; for (int i = 0; i <; 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 = {"Capricorn", "Aquarius",            "Pisces", "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius"};  Int[] Dayarr = {22, 20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22};            Two constellation dividing day int index = month;            The query date is before the partition date, index-1, otherwise unchanged if (Day < dayarr[month-1]) {index = index-1;            index = index% 12;        Returns the constellation that the index points to, string return Stararr[index]; }    }}

  

Late-night brain hole, wrote a small program that can calculate the ID number of a train ticket

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.