用JAVA语句写一个程序,可以输出近10年的历法。

来,来:

导入Java . io . *;

类别输出{

公共void输出(int f,int x,int y){

int I;

int a[]= new int[40];

System.out.println("第123456天"+" "+f+ F+"月");

for(I = 0;我& ltx;i++)

{ system . out . print(" ");}

for(I = x;我& ltx+y;i++)

a[I]= I-x+1;

for(I = x;我& ltx+y;i++)

{

if((I % 7 = = 0)& amp;& amp(我& gt0))

system . out . print(" \ n ");

if(a[I]& lt;10)

system . out . print("+a[I]);

else system . out . print("+a[I]);

}

system . out . println(" \ n ");

}

}

st级

公共静态void main(String args[])引发IOException{

putout p = new putout();

int year,mouth,y=1,t,I;

InputStreamReader ir

BufferedReader在;

IR = new InputStreamReader(system . in);

in = new buffered reader(IR);

System.out.print("请输入年份:");

string s = in . readline();

year = integer . parse int(s);

if((year % 4 = = 0 & amp;& amp年份%100!=0)||(年份%400==0))

口= 1;

其他

mouth = 0;

y =年份;

for(I = 1;我& lt年份;i++)

{ if((I % 4 = = 0 & amp;& amp我%100!=0)||(i%400==0))

y++;}

y = y % 7;

for(I = 1;我& lt13;i++){

开关(i){

案例1: {p.putout(1,y,31);y =(y+31)% 7;打破;}

案例二:{p.putout(2,y,28+口);y =(y+28+口)% 7;打破;}

案例三:{p.putout(3,y,31);y =(y+31)% 7;打破;}

情况4: {p.putout(4,y,30);y =(y+30)% 7;打破;}

案例五:{p.putout(5,y,31);y =(y+31)% 7;打破;}

案例6: {p.putout(6,y,30);y =(y+30)% 7;打破;}

案例7: {p.putout(7,y,31);y =(y+31)% 7;打破;}

案例8: {p.putout(8,y,31);y =(y+31)% 7;打破;}

情况9: {p.putout(9,y,30);y =(y+30)% 7;打破;}

案例10: {p.putout(10,y,31);y =(y+31)% 7;打破;}

案例11:{ p . putout(11,y,30);y =(y+30)% 7;打破;}

案例12: {p.putout(12,y,31);y =(y+31)% 7;打破;}

}

}

}

}

写起来比较复杂,就给你一个好用的吧。