主题:求求你
我是严天雯
[专家分:110] 发布于 2006-12-07 19:04:00
由键盘输入年月,输出该月的月历。快回复
回复列表 (共4个回复)
沙发
zhangyuan [专家分:630] 发布于 2006-12-07 19:05:00
program yb(input,output);
var
year,month:integer;
m,n,i:integer;
function get_week(year:integer):integer;
var
x:integer;
begin
x:=year+(year-1) div 4 -(year-1) div 100 + (year-1) div 400;
get_week:=x mod 7;
end;
function leap(year:integer):boolean;
begin
leap:=false;
if year mod 100=0 then
if year mod 400=0 then
begin
leap:=true;
exit;
end
else exit;
if year mod 4=0 then leap:=true;
end;
function getdaysNum(year,month:integer):integer;
var
x:integer;
begin
case month of
1,3,5,7,8,10,12: x:=31;
2: if leap(year) then x:=29
else x:=28;
4,6,9,11: x:=30;
end;
getdaysNum:=x;
end;
begin
write('Enter year: '); readln(year);
write('Enter month: '); readln(month);
m:=get_week(year);
n:=0;
for i:=1 to month-1 do
n:=n+getdaysNum(year,i);
m:=(m+n) mod 7;
writeln;
writeln(year,'-',month);
writeln('SUN':6,'MON':6,'TUE':6,'WED':6,'THU':6,'FRI':6,'SAT':6);
for i:=0 to m-1 do write(' ':6);
n:=getdaysNum(year,month);
for i:=1 to n do
begin
write(i:6);
m:=m+1;
if m mod 7=0 then writeln;
end;
writeln;
end.
板凳
sss333 [专家分:340] 发布于 2006-12-08 15:47:00
[quote]program yb(input,output);
var
year,month:integer;
m,n,i:integer;
function get_week(year:integer):integer;
var
x:integer;
begin
x:=year+(year-1) div 4 -(year-1) div 100 + (year-1) div 400;
get_week:=x mod 7;
end;
function leap(year:integer):boolean;
begin
leap:=false;
if year mod 100=0 then
if year mod 400=0 then
begin
leap:=true;
exit;
end
else exit;
if year mod 4=0 then leap:=true;
end;
function getdaysNum(year,month:integer):integer;
var
x:integer;
begin
case month of
1,3,5,7,8,10,12: x:=31;
2: if leap(year) then x:=29
else x:=28;
4,6,9,11: x:=30;
end;
getdaysNum:=x;
end;
begin
write('Enter year: '); readln(year);
write('Enter month: '); readln(month);
m:=get_week(year);
n:=0;
for i:=1 to month-1 do
n:=n+getdaysNum(year,i);
m:=(m+n) mod 7;
writeln;
writeln(year,'-',month);
writeln('SUN':6,'MON':6,'TUE':6,'WED':6,'THU':6,'FRI':6,'SAT':6);
for i:=0 to m-1 do write(' ':6);
n:=getdaysNum(year,month);
for i:=1 to n do
begin
write(i:6);
m:=m+1;
if m mod 7=0 then writeln;
end;
writeln;
end.
[/quote]
3 楼
风神少年 [专家分:730] 发布于 2006-12-08 16:03:00
怎么题目都是求求你??
4 楼
风神少年 [专家分:730] 发布于 2006-12-08 16:04:00
发点别的
我来回复