首页 > 编程 > Java > 正文

java实现——2005第几天?

2019-11-06 06:11:46
字体:
来源:转载
供稿:网友
import java.util.GregorianCalendar;import java.util.Scanner;public class Main{		public static void main(String args[]){		Scanner scan = new Scanner(System.in);		while(scan.hasNext())		{			int sum = 0;			int arrMonth[][] = {{0},{31},{28},{31},{30},{31},{30},{31},{31},{30},{31},{30}};			String arr[] = scan.nextLine().split("/");			int year = Integer.parseInt(arr[0]);			int month = Integer.parseInt(arr[1]);			int day = Integer.parseInt(arr[2]);			sum = day;			GregorianCalendar c = new GregorianCalendar();			if(year%4==0&&year%100!=0||year%400==0){				if(month>2)					sum++;			}			for(int i=1; i<month; ++i)			{				sum += arrMonth[i][0];			}			System.out.PRintln(sum);					}	}}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表