A few interesting algorithms (Gauss Diary, the number of square, the rejuvenation of the new, reversed the price card) __ algorithm

Source: Internet
Author: User
1. Topic Title: Gauss Diary

Gauss, the great mathematician, has a good habit of keeping a diary in any case.

His diary has a different place, he never dated, but with an integer instead of, for example: 4210

Later, people knew that the whole number was a date, which means that it was the day after Gauss was born. It may also be a good habit to remind the owner: How much time can be wasted when the days go by.

Gauss was born in: April 30, 1777.

The diary of an important theorem in Gauss's discovery is labeled: 5343, so it can be calculated that day is: December 15, 1791.

Gauss got his Ph. D. Journal on the day marked: 8113

Please calculate the date of Gauss's doctorate.

The format for submitting the answer is: YYYY-MM-DD, for example: 1980-03-21

Please submit the answer in the browser in strict accordance with the format.
Note: Only submit this date, do not write additional content, such as: descriptive text.

Analysis: This is actually "Santian, two days problem".

Program implementation: (Java Write)[Java]  View plain copy package forth;      public class dateofndays {   /*   *  Gaussian Diary (given date, calculate the date of X days)    */       /*        *  is leap year        */        Boolean isleapyear (int year) {           return   (year % 400 == 0 | |  year % 4 == 0 && year % 100 != 0);       }              /*       *  get the maximum number of days of a certain month        */        int getmaxday (int year,int month,int day) {            switch (month) {    &NBsp;      case 1:            case 3:           case 5:            case 7:            case 8:           case 10:            case 12:                return 31;           case  4:           case 6:            case 9:           case  11:               return 30;    &NBsp;       case 2:                return  (Isleapyear (year) 29:28);            default:                return -1;           }        }       /*       

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.