Use Java to easily get rid of the Third Session of the Tencent programming marathon

Source: Internet
Author: User

Http://acm.hdu.edu.cn/contests/contest_showproblem.php? PID = 1001 & cid = 439

Java is really good and powerful. As long as the Java foundation is better, such a question is simple.

Note that the month and date of the calendar class are not prefixed with 0 if they are less than 10, which is inconsistent with the requirement of the subject. So useSystem. Out. printf ("% d/% 02d/% 02d", year, month, day );This form controls the output format. Similar to the prinf function in C.

In addition, the calendar month class is one month smaller than the actual month.

Import Java. util. calendar; import Java. util. extends; public class main {public static void main (string [] ARGs) {// todo auto-generated method stubscanner S = new evaluate (system. in); Calendar c = calendar. getinstance (); int N, D; n = S. nextint (); For (INT I = 1; I <= N; I ++) {d = S. nextint (); C. set (maid); C. add (calendar. date, d); system. out. printf ("% d/% 02d/% 02d", C. get (calendar. year), (C. get (calendar. month) + 1), C. get (calendar. date); system. out. print (""); C. set (maid); C. add (calendar. date,-d); system. out. printf ("% d/% 02d/% 02d", C. get (calendar. year), (C. get (calendar. month) + 1), C. get (calendar. date); system. out. println ();}}}

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.