4个回答
展开全部
如果是实用的话,可用Pascal自带的getdate函数
如果是编程题目就用下面的代码,先输入:年 月 日
var
res,year2,year1,month1,day1,k,m2:integer;
begin
read(year1,month1,day1);
if((year1 mod 4=0) and (year1 mod 100<>0)) or (year1 mod 400 =0) then
m2:=29
else
m2:=28;
year2:=year1-1;
res:=year2 div 4-year2 div 100+ year2 div 400+year2*365+day1+1;
for k:=1 to month1-1 do
if k=2 then
res := res+m2
else if (k=1) or (k=3) or (k=5) or (k=7) or (k=8) or (k=10) then
res := res+31
else
res := res+30;
k := res mod 7;
writeln(year1,'-',month1,'-',day1,' is ', k, ' of week');
end.
如果是编程题目就用下面的代码,先输入:年 月 日
var
res,year2,year1,month1,day1,k,m2:integer;
begin
read(year1,month1,day1);
if((year1 mod 4=0) and (year1 mod 100<>0)) or (year1 mod 400 =0) then
m2:=29
else
m2:=28;
year2:=year1-1;
res:=year2 div 4-year2 div 100+ year2 div 400+year2*365+day1+1;
for k:=1 to month1-1 do
if k=2 then
res := res+m2
else if (k=1) or (k=3) or (k=5) or (k=7) or (k=8) or (k=10) then
res := res+31
else
res := res+30;
k := res mod 7;
writeln(year1,'-',month1,'-',day1,' is ', k, ' of week');
end.
展开全部
uses dos,crt;
const local=20;
var y,m,d,hh,mm,ss,w,ms:word;a,b,c:boolean;
begin
textbackground(1);
textcolor(7);
clrscr;
cursoroff;
gotoxy(local,12);
writeln('____________DATE&TIME____________');
while not keypressed do
begin
getdate(y,m,d,w);
gettime(hh,mm,ss,ms);
gotoxy(local+12,13);
write(y,'/',m,'/',d,' ');
case w of
1:writeln('Monday');
2:writeln('Tuesday');
3:writeln('Wednesday');
4:writeln('Thursday');
5:writeln('Friday');
6:writeln('Saturday');
7:writeln('Sunday');
end;
a:=false;b:=false;c:=false;
gotoxy(local+12,14);
if hh<10 then a:=true;
if mm<10 then b:=true;
if ss<10 then c:=true;
if a then write('0');
write(hh,':');
if b then write('0');
write(mm,':');
if c then write('0');
write(ss,'.',ms);
end;
end.
除了求星期几外,还可以用来看时间……
按任意键结束
const local=20;
var y,m,d,hh,mm,ss,w,ms:word;a,b,c:boolean;
begin
textbackground(1);
textcolor(7);
clrscr;
cursoroff;
gotoxy(local,12);
writeln('____________DATE&TIME____________');
while not keypressed do
begin
getdate(y,m,d,w);
gettime(hh,mm,ss,ms);
gotoxy(local+12,13);
write(y,'/',m,'/',d,' ');
case w of
1:writeln('Monday');
2:writeln('Tuesday');
3:writeln('Wednesday');
4:writeln('Thursday');
5:writeln('Friday');
6:writeln('Saturday');
7:writeln('Sunday');
end;
a:=false;b:=false;c:=false;
gotoxy(local+12,14);
if hh<10 then a:=true;
if mm<10 then b:=true;
if ss<10 then c:=true;
if a then write('0');
write(hh,':');
if b then write('0');
write(mm,':');
if c then write('0');
write(ss,'.',ms);
end;
end.
除了求星期几外,还可以用来看时间……
按任意键结束
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
添加dateutils单元,用dayoftheweek(1980-01-01)函数,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没分。。谁愿意麻烦去写。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询