import java.util.Scanner;
public class Test1{
public static int ri(int n){ //ri函数判断这一月的天数
int tian=0;
switch(n){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:tian=31;break;
case 4:
case 6:
case 9:
case 11:tian=30;break;
case 2: if((n%4==0&&n%100!=0)||n%400==0)
tian=29;break;
else
tian=28;break;
}
return tian;
}
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("请输入年月日");
int year = sc.nextInt();
int month = sc.nextInt();
int day = sc.nextInt(); //输入年月日
int days=0,i,j,count=0,y=0; //days代表相距1989 1.1的天数,count用来计数闰年,y用来对天数求余
boolean run = false; //判断是否为闰年
if(day<1||day>31)
System.out.println("请输入正确的日数");
if(month<1||month>12)
System.out.println("请输入正确的月份");
if(year>=1989){ //年份大于等于1989年情况
for(i=1989;i<=year;i++){
if(i==year){
for(j=1;j<=month;j++){
if(j==month){
days += day-1;
break;
}
days += ri(j);
}
}
else{
if((i%4==0&&i%100!=0)||i%400==0){
days += 366;
}
else{
days += 365;
}
}
}
}
if(year<1989){ //年份小于1989年情况
for(i=year;i<1989;i++){
if(i==year){
for(j=1;j<=month;j++){
if(j==month){
days += day;
}
days += ri(j);
}
if((i%4==0&&i%100!=0)||i%400==0){
run = true;
}
if(true)
days=366-days;
else
days=365-days;//当小于1989年时,用第一年总天数减去已经过去的天数
System.out.println(days);
}
else{
if((i%4==0&&i%100!=0)||i%400==0){
run = true;
}
if(true){
days += 366;
}
else{
days += 365;
}
}
}
}
y = days%7;
if(year>=1989){
switch(y){
case 0: System.out.print(year+"年"+month+"月"+day+"日"+"是星期日");break;
case 1: System.out.print(year+"年"+month+"月"+day+"日"+"是星期一");break;
case 2: System.out.print(year+"年"+month+"月"+day+"日"+"是星期二");break;
case 3: System.out.print(year+"年"+month+"月"+day+"日"+"是星期三");break;
case 4: System.out.print(year+"年"+month+"月"+day+"日"+"是星期四");break;
case 5: System.out.print(year+"年"+month+"月"+day+"日"+"是星期五");break;
case 6: System.out.print(year+"年"+month+"月"+day+"日"+"是星期六");break;
}
}
if(year<1989){
switch(y){
case 0: System.out.print(year+"年"+month+"月"+day+"日"+"是星期六");break;
case 1: System.out.print(year+"年"+month+"月"+day+"日"+"是星期五");break;
case 2: System.out.print(year+"年"+month+"月"+day+"日"+"是星期四");break;
case 3: System.out.print(year+"年"+month+"月"+day+"日"+"是星期三");break;
case 4: System.out.print(year+"年"+month+"月"+day+"日"+"是星期二");break;
case 5: System.out.print(year+"年"+month+"月"+day+"日"+"是星期一");break;
case 6: System.out.print(year+"年"+month+"月"+day+"日"+"是星期日");break;
}
}
}
}
import java.util.Scanner;
public class Test2{
public static int ri(int n){ //ri函数判断这一月的天数
int days=0;
switch(n){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:days=31;break;
case 4:
case 6:
case 9:
case 11:days=30;break;
case 2: if(n%4==0&&n%100!=0||n%400==0)
days=29;
else
days=28;break;
}
return days;
}
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("请输入年月");
int year = sc.nextInt();
int month = sc.nextInt();//输入年月
int day=1,days=0,i,j,k,l,y=0; //days代表相距1989 1.1的天数,count用来计数闰年,y用来对天数求余
boolean run = false;
if(month<1||month>12)
System.out.println("请输入正确的月份");
if(year>=1989){
for(i=1989;i<=year;i++){
if(i==year){
for(j=1;j<=month;j++){
if(j==month){
days += day-1;
break;
}
days += ri(j);
}
}
else{
if(i%4==0&&i%100!=0||i%400==0){
days += 366;
}
else{
days += 365;
}
}
}
}
if(year<1989){
for(i=year;i<1989;i++){
if(i==year){
for(j=1;j<=month;j++){
if(j==month){
days += day;
break;
}
days += ri(j);
}
if(i%4==0&&i%100!=0||i%400==0){
run = true;
}
if(true)
days=366-days;
else
days=365-days;//当小于1989年时,用第一年总天数减去已经过去的天数
}
else{
if(i%4==0&&i%100!=0||i%400==0){
run = true;
}
if(true){
days += 366;
}
else{
days += 365;
}
}
}
}
y = days%7;
if(year>=1989){
System.out.println("日 一 二 三 四 五 六");
for(k=1;k<=ri(month);k++){
for(l=1;l<=y;l++){
System.out.print(" ");
}
System.out.print(k+" ");
if((k+l-1)%7==0){
System.out.println("");
}
}
}
if(year<1989){
switch(y){
case 0: System.out.print(year+"年"+month+"月"+day+"日"+"是星期六");break;
case 1: System.out.print(year+"年"+month+"月"+day+"日"+"是星期五");break;
case 2: System.out.print(year+"年"+month+"月"+day+"日"+"是星期四");break;
case 3: System.out.print(year+"年"+month+"月"+day+"日"+"是星期三");break;
case 4: System.out.print(year+"年"+month+"月"+day+"日"+"是星期二");break;
case 5: System.out.print(year+"年"+month+"月"+day+"日"+"是星期一");break;
case 6: System.out.print(year+"年"+month+"月"+day+"日"+"是星期日");break;
}
System.out.println("日 一 二 三 四 五 六");
for(k=1;k<=ri(month);k++){
for(l=1;l<=y;l++){
System.out.print(" ");
}
System.out.print(k);
if((k+l-1)%7==0){
System.out.println("");
}
}
}
}
}