package _2005; import java.util.Scanner; public class Main { public static void main(String [] args){ Scanner scan = new Scanner(System.in); while (scan.hasNext()){ String ss = scan.next(); /*按'/'分裂字符串为string数组*/ String tt[] = ss.split("/"); int year = Integer.parseInt(tt[0]); int month = Integer.parseInt(tt[1]); int day = Integer.parseInt(tt[2]); int months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int ans = day; for (int i = 1; i < month; ++i){ ans += months[i]; } /*判断是否是闰年*/ if (0 == year % 400 || (0 == year % 4 && 0 != year % 100)){ if (month > 2){ ans += 1; } } System.out.println(ans); } } }
hdu_2005 第几天
最新推荐文章于 2022-09-19 18:34:38 发布