int daies=0;
Scanner input=new Scanner(System.in);
System.out.println(" 2018年3月");
System.out.println("输入年");
System.out.println("输入月");
int year=input.nextInt();
int month=input.nextInt();
int b=0;
for(int a=1;a<=month;a++){
switch(month){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
daies=31;break;
case 4: case 6: case 9: case 11:
daies=30;break;
case 2:
if(year%4==0&&(year%100!=0)||year%400==0){
daies=29;
}else{daies=28;}break;
}
if(a<month){
b=b+daies;}
}
System.out.println(year+"年"+month+"月"+"有"+daies+"天");
int sum=0;
for(int i=1900;i<2018 ;i++){
if(i%4==0&&(i%100!=0)||i%400==0){
sum=sum+366;
}
else{
sum=sum+365;} }
sum=sum+b;
int f;//该月第一天是周几
int d=sum%7+1;//是1-6的话为周一到周六,0的话是周末
if(d==7){f=0;}
else{f=d;}
System.out.println("日\t一\t二\t三\t四\t五\t六"); //打印表格
for(int a=0;a<f;a++){
System.out.print("\t");
}
for(int c=1;c<=daies;c++){
System.out.print(c+"\t");
if((sum+c)%7==6){//每到周六就换行
System.out.print("\n");}
}
}
}
Scanner input=new Scanner(System.in);
System.out.println(" 2018年3月");
System.out.println("输入年");
System.out.println("输入月");
int year=input.nextInt();
int month=input.nextInt();
int b=0;
for(int a=1;a<=month;a++){
switch(month){
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
daies=31;break;
case 4: case 6: case 9: case 11:
daies=30;break;
case 2:
if(year%4==0&&(year%100!=0)||year%400==0){
daies=29;
}else{daies=28;}break;
}
if(a<month){
b=b+daies;}
}
System.out.println(year+"年"+month+"月"+"有"+daies+"天");
int sum=0;
for(int i=1900;i<2018 ;i++){
if(i%4==0&&(i%100!=0)||i%400==0){
sum=sum+366;
}
else{
sum=sum+365;} }
sum=sum+b;
int f;//该月第一天是周几
int d=sum%7+1;//是1-6的话为周一到周六,0的话是周末
if(d==7){f=0;}
else{f=d;}
System.out.println("日\t一\t二\t三\t四\t五\t六"); //打印表格
for(int a=0;a<f;a++){
System.out.print("\t");
}
for(int c=1;c<=daies;c++){
System.out.print(c+"\t");
if((sum+c)%7==6){//每到周六就换行
System.out.print("\n");}
}
}
}