标签:end 打印 buffere [] AC == adl i++ read
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Calendar;
public class NianLi {
public static void main(String[]args) throws IOException{
//缓冲输入流
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入日期,如yyyy");
String rq=br.readLine();
int d=Integer.parseInt(rq);
for(int m=0;m<=11;m++){
Calendar c=Calendar.getInstance();
c.set(Calendar.YEAR, d);
c.set(Calendar.MONTH,m);
//当前日期中当前月对应的最大天数
int allDay=c.getActualMaximum(Calendar.DAY_OF_MONTH);
//当前日期中当前月第一天对应的星期数
c.set(Calendar.DAY_OF_MONTH, 1);
int firstDay = c.get(Calendar.DAY_OF_WEEK);
System.out.println("\t\t第"+(m+1)+"月的月历");
System.out.println("日\t一\t二\t三\t四\t五\t六");
c.set(Calendar.MONTH,m);
for (int j = 1; j < firstDay; j++) {
System.out.print("\t");
}
for (int i = 1; i <= allDay; i++) {
System.out.print(i + "\t");
//每到星期六就换行
c.set(Calendar.DATE, i);
if (c.get(Calendar.DAY_OF_WEEK) % 7 == 0) {
System.out.println("\n");
}
}
System.out.println("\n");
}
}
}
标签:end 打印 buffere [] AC == adl i++ read
原文地址:https://www.cnblogs.com/bronze-y/p/9032180.html