In the middle of the night, I wrote a program to calculate the train ticket ID card number.
1. the number * on a train ticket is a month or day. Theoretically, there are a maximum of 366 combinations;
2. The verification code is the last one, with 0-9 and X and 11 results;
3. You can get about 33 valid ID card numbers through the ID card number on the train ticket;
4. if you know the constellation of the other party (well, don't you often expose yourself as a constellation), then map these 30 results to 12 constellations, the final possibility is only 2-3...
5. Conclusion: The ticket must be stamped.
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 card number on the train ticket:"); String a = System. console. readLine (); var year = int. parse (. substring (6, 4); var beginDate = new DateTime (year, 1, 1); var chk =. 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 =. 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 = {"Capricorn", "Aquarius ", "Pisces", "Aries", "Taurus", "Gemini", "cancer", "Leo", "Virgo", "Libra", "scorpio ", "Sagittarius"}; int [] DayArr = {22, 20, 19, 21, 21, 21, 22, 23, 23, 23, 22 }; // int index = month for the split day of the Two constellations; // index-1 before the date to be queried; otherwise, if (day <DayArr [month-1]) is not changed. {index = index-1 ;}index = index % 12; // returns the constellation string return starArr [index] pointing to the index; }}}