Welcome

首页 / 软件开发 / 数据结构与算法 / UVa 893 Y3K Problem:用GregorianCalendar类秒杀

UVa 893 Y3K Problem:用GregorianCalendar类秒杀2014-07-07 synapse7 http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=834

不解释。

完整代码:

01.import java.util.*;02.import java.io.*;03.04.public class Main {05.static Scanner cin = new Scanner(new BufferedInputStream(System.in));06.07.public static void main(String[] args) {08.int n, d, m, y;09.while (true) {10.n = cin.nextInt();11.d = cin.nextInt();12.m = cin.nextInt();13.y = cin.nextInt();14.if (d == 0)15.break;16.GregorianCalendar cal = new GregorianCalendar(y, m - 1, d);//Month值是基于0的17.cal.add(Calendar.DATE, n);18.System.out.println(cal.get(Calendar.DATE) + " " + (cal.get(Calendar.MONTH) + 1) + " " + cal.get(Calendar.YEAR));19.}20.}21.}