日全食 pascal程序
发布网友
发布时间:2022-10-13 20:51
我来回答
共1个回答
热心网友
时间:2023-12-04 20:29
program sunfood;
Var s:array[1..3] of integer; n:integer;
begin writeln('please input the number over 0'); readln(n);
s[1]:=2008; s[2]:=1;
while s[1]<=2250 do begin
s[2]:=s[2]+18; if s[2]<10 then begin
writeln(s[1],'nian','':3,'0',s[2],'yve'); end;
if (s[2]>=10) and (s[2]<=12) then begin
writeln(s[1],'nian','':3,s[2],'yve'); end;
if (s[2]>12) and(s[2]<22) then begin
s[1]:=s[1]+1; s[2]:=s[2]-12;
writeln(s[1],'nian','':3,'0',s[2],'yve');
end; if (s[2]>=22) and (s[1]<=24) then begin
s[1]:=s[1]+1; s[2]:=s[2]-12;
writeln(s[1],'nian','':3,s[2],'yve'); end;
if s[2]>24 then begin
s[1]:=s[1]+2; s[2]:=s[2]-24;
writeln(s[1],'nian','':3,'0',s[2],'yve'); end;
s[3]:=s[3]+1; if s[3]=n then begin
s[1]:=3500; end; end;
readln;
end.
这是我的程序,固然很烦,可是答案很精确,严密。使用了数组s[1..3],以节省内存,加快速度。且可以通过更改,输入年和月和n,求出第n次全食的时间,不会有误。