10

# CCF节日问题（测试不完全正确）

/*问题描述

5 2 7 2014 2015

2014/05/11
2015/05/10

import java.util.*;
public class Festival
{
public static void main(String [] args)
{
Scanner sc = new Scanner(System.in);
int month = sc.nextInt();
int num = sc.nextInt();
int week = sc.nextInt();
int begin_year = sc.nextInt();
int end_year = sc.nextInt();
begin_year = Math.min(begin_year,end_year);
end_year = Math.max(begin_year,end_year);
disPlay(month,num,week,begin_year,end_year);
}
public static void disPlay(int month,int num,int week,int begin_year,int end_year) //显示输出begin_year~end_year之间的情况。
{
for(int i = begin_year ; i<= end_year ; i++)
{
print(month,num,week,i);
}
}
public static void print(int month,int num,int week,int year)//显示输出某年的情况。
{
int temp = week+7-getMonthFirst(year,month)+1;
int day = 0;
if(temp!=7)
day = (week+7-getMonthFirst(year,month)+1)%7+(num-1)*7;
else
day = (week+7-getMonthFirst(year,month)+1)%7+num*7;
if(day<=DaysPerMonth(year,month))
{
}
else
System.out.println("none");
}
{
if(month_or_day<10)
return 0+Integer.toString(month_or_day);
else
return Integer.toString(month_or_day);
}
public static int getMonthFirst(int year,int month)//获取某年某月的第一天星期几
{
return (int)((DaysAll(year,month)%7+2)%7);
}
public static int DaysPerMonth(int year,int month)//获取某年某月的天数
{
int days = 0;
switch(month)
{
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10 :
case 12 :
days = 31;
break;
case 2:
if(judgeYear(year)==true)
days = 29;
else
days = 28;
break;
case 4 :
case 6 :
case 9 :
case 11 :
days = 30;
break;
}
return days;
}
public static long getDaysYears(int year)//获取从1850至某年（不包含）的总天数
{
int count = 0;
for(int i=1850 ; i<year ; i++)
{
if(judgeYear(i)==true)
count++;
}
return 366*count+365*(year-1850-count);
}
public static boolean judgeYear(int year)//判断平闰年
{
if((year%400==0)||((year%4==0)&&(year%100!=0)))
return true;
return false;
}
public static long DaysAll(int year,int month)//获取从1850/01/01至某年某月（不包含）的总天数
{
for(int i=1;i<month;i++)
{
}
}
}

2015/08/28 03:01
• java
• ccf
• 点赞
• 收藏
• 回答
私信