import java.util.Calendar
import scala.io.StdIn
object YearBook {
def main(args: Array[String]): Unit = {
println("请输入年份:")
val year=StdIn.readInt()
println("请输入月份:")
val month=StdIn.readInt()
var days=0
if(year%4==0&&year%100!=0||year%400==0){
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
days=31
}else if(month==4||month==6||month==9||month==11){
days=30
}else{
days=29
}
}else{
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
days=31
}else if(month==4||month==6||month==9||month==11){
days=30
}else{
days=28
}
}
val calendar = Calendar.getInstance()
calendar.set(Calendar.YEAR,year)
calendar.set(Calendar.MONTH,month-1)
calendar.set(Calendar.DAY_OF_MONTH,1)
//计算该月的第一天是周几
var week =calendar.get(Calendar.DAY_OF_WEEK)
//计数
var count=0
println("星期天\t星期一\t星期二\t星期三\t星期四\t星期五\t星期六")
//打印空格
for(i <- 0 until week-1){
count+=1
print("\t"+"\t")
}
//打印天
for(i<- 1 to days){
count+=1
print(i+"\t"+"\t")
if(count%7==0){
println()
}
}
}
}