Java Common Algorithm questions (14)

Source: Internet
Author: User

 PackageCom.xiaowu.demo;/*** Enter a certain month of the year, judging the day is the first of the year? *  *  * @authorWQ **/ Public classDemo14 { Public Static voidMain (string[] args) {year (2017, 6, 5); }              /*** * Common year February 28 days, leap year February 29 days.          * Year number (last two bits not 00) can be divisible by 4 is a leap year (such as 1988, 1996), the number of years (the last two digits is 00) can be divisible by 400 is also a leap year (such as 2000, 4000). The rest is common year. *           *           *           * @paramYear *@paramMonth *@param Day*/         Public Static voidYearintYearintMonthintDay ) {            intd = 0; intDays = 0; if(Year < 0 | | Month < 0 | | month > | |-day < 0 | | Day > 31) {System.out.println ("Input error, please re-enter!" "); }             for(inti = 1; I < month; i++) {                Switch(i) { Case1:                 Case3:                 Case5:                 Case7:                 Case8:                 Case10:                 Case12: Days= 31;  Break;  Case4:                 Case6:                 Case9:                 Case11: Days= 30;  Break;  Case2:                    if(Year% 400 = = 0) | | (year% 4 = = 0 && Year% 100! = 0) ) { days= 29; } Else{ days= 28; }                     Break; } d+=Days ; } System.out.println ( year+ "Years" + month + "Month" + Day + "date" + year + "+" + (d + days) + "Tian". "); }}

Java Common Algorithm questions (14)

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.