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 ();}}}