标签:
import java.util.Scanner; public class CountDays { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int year = scan.nextInt(); int month = scan.nextInt(); int day = scan.nextInt(); int []a = {31,28,31,30,31,30,31,31,30,31,30,31}; int []b = {31,29,31,30,31,30,31,31,30,31,30,31}; if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0) countDays(b,month,day); else countDays(a, month, day); } private static void countDays(int[] arr, int month, int day) { int sum = 0; for (int i = 0; i < month-1; i++) { sum += arr[i]; } sum += day; System.out.println(sum); } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/liaction/article/details/47784033