Java Waterloo Cup Gauss Diary

Source: Internet
Author: User

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.


Import java.util.*;


public class main{public

	static void Main (String args[])
	{
		Scanner cn=new Scanner (system.in);
		int Data=cn.nextint ();
		Calendar cc=calendar.getinstance ()//Get system time
		Cc.set (1777, 3, 30);//change system time  setup time because the month in the system is 0-11 so April is actually 3
		. int count=0;
		while (true)
		{
			cc.add (cc. Date, 1);/Let the day count++ day back
			;
			
			if (count==data) break;
		System.out.println (Cc.get (calendar.year) + "-" + (Cc.get (calendar.month) +1) + "-" + (Cc.get (calendar.date)-1));
		The output of the month and then add a plus back
	}
	
	
}



The result is 1799-7-16.


Note that this topic is Gauss's birth date as the first day, so I subtract the day from the final output statement because I'm talking about the first day after birth, which is number 5-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.