C # Console Program-"Enter the day of the week for the specified month"

Source: Internet
Author: User

It involves an algorithm:

Kimlarsson Calculation Formulaw= (d+2*m+3* (m+1)/5+y+y/4-y/100+y/400+1) MoD 7in the formula, D represents the number of days in a date, m represents the number of months, and Y represents the number of years. Note: There is a difference in the formula from the other formulas:consider January and February as the January or March and January or April of the previous year, as in the case of 2004-1-10:2003-13-10 is calculated by substituting the formula. The code is as follows:

 Console.Wri            Teline ("**************************");            Console.WriteLine ("Enter the day of the month specified)";            Console.WriteLine ("By:yys"); Console.WriteLine ("Today is {0} year {1} month {2} day week {3}", Datetime.now.year,datetime.now.month, DateTime.Now.Day, (int)            DateTime.Now.DayOfWeek);            Console.WriteLine ("**************************");            Console.foregroundcolor = consolecolor.red;            Console.WriteLine ("Please enter the Year:");            int y = System.Int32.Parse (Console.ReadLine ());            Console.WriteLine ("Please enter the month");            int m = System.Int32.Parse (Console.ReadLine ());            Console.WriteLine ("Please enter the day");            int d = System.Int32.Parse (Console.ReadLine ());            Int week = (d + 2 * m + 3 * (M + 1)/5 + y + Y/4-y/100 + y/400 + 1)% 7;            Console.WriteLine ("{0} year {1} month {2} days is week {3}", Y,m,d,week); Console.readkey (); 


C # Console Program-"Enter the day of the week for the specified month"

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.