我的思路是输入06年后的任一年份,然后打印这年的各个月份
import java.io.*;
public class getDataed
{
public static void main(String args[])throws IOException
{ int q;
String s=new String();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("输入2006或以后的年份");//2006年的元旦刚好是星期日
s=br.readLine();
q=Integer.parseInt(s);
Dataed dataed=new Dataed(q);
}
}
class Dataed
{ private int nian,n,d,sum=0;
private int arr[]={31,28,31,30,31,30,31,31,30,31,30,31};
private String zhou[]={"日","一","二","三","四","五","六"};
public Dataed(int p)
{this.nian=p;}
public boolean istrue()
{ if(nian%4==0&&nian%100!=0||nian%100==0&&nian%400==0)
return true;
}
public void printyue()
{ if(istrue()) arr[1]=29;
for(int i=0;i<arr.length;i++)
{ System.out.println((i+1)+"月");
for(int j=0;j<zhou.length;j++)
System.out.print(zhou[j]+"\t");
System.out.println();
int r=1,count=1;
for(int s=1;s<=arr[i];s++)
{ if(r==1)
{ getday();
d=d-1;
r++;
}
if(count>1) d=0;
System.out.print(s+"\t");
if((s+d)%7==0)
{System.out.println();
count++;}
}
System.out.println();
}
}
public void getday()
{ int t=nian-2006;
n=t/4;
sum=(t-n)*365+n*366;
d=sum%7;
for(int i=1;i<d;i++)
System.out.print(" "+"\t");
}
}
年历打印问题