package School;
import java.util.Scanner;
public class Test02 {
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
System.out.println("请输入整数年:");
int year=scn.nextInt();
int month=12;
int total=0;
for(int y=1;y<year;y++) {
if(y%4==0&&y%100!=0||y%400==0) {
total=total+366;
}
else {total=total+365;
}
}
for(int s=1;s<=month;s++) { //加的
int m=1;
while(m<=month) {
switch(m) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
total=total+31;
break;
case 4:
case 6:
case 9:
case 11:
total=total+30;
break;
case 2:
if(year%4==0&&year%100!=0||year%400==0) {
total=total+29;
}
else {
total=total+28;
}
}
m++;
}
total=total+1;
int first=total%7;
int mdays=0;
switch(month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
mdays=31;
break;
case 4:
case 6:
case 9:
case 11:
mdays=30;
break;
case 2:
if(year%4==0&&year%100!=0||year%400==0) {
mdays=29;
}
else {
mdays=28;
}
}
String[]title= {"天","一","二","三","四","五","六"};
String space=" ";
for(int i=0;i<title.length;i++) {
System.out.print(space+title[i]);
}
System.out.println();
for(int i=0;i<first;i++) {
System.out.print(space+" ");
}
for(int d=1;d<=mdays;d++) {
if((d+first-1)%7==0) {
System.out.println();
}
if(d<10) {
System.out.print(space+" "+d);
}
else {
System.out.print(space+d);
}
}System.out.println(); //
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/119633.html