标签:
import java.util.Scanner; public class Main { static int getweekoffirstday(int y){ int i=1998,week=3; int days=0; for(i=1998;i<y;i++){ if(i%400==0||(i%4==0&&i%100!=0)) days+=366; else days+=365; } return (days+week)%7; } static void print(int y){ int day[][]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}}; int week=getweekoffirstday(y),flag=y%400==0||(y%4==0&&y%100!=0)?1:0; int times=0,i,days=0; for(i=0;i<12;i++){ if((days+12+week)%7==4) times++; days+=day[flag][i]; } System.out.println(times); } public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int y=sc.nextInt(); print(y); } }
标签:
原文地址:http://www.cnblogs.com/watchfree/p/5346940.html