2006日历

  用DELPHI写的一段2006年日历程序,不过我觉得我的方法好象太麻烦了,希望有人提供更好的算法。

var
s,a:integer;
begin
s:=strtoint(edit1.Text);
if edit2.Text='1' then
a:=(s-1) mod 7;
if edit2.Text='2' then
a:=(31+s-1) mod 7;
if edit2.Text='3' then
a:=(31+28+s-1) mod 7;
if edit2.Text='4' then
a:=(31+28+31+s-1) mod 7;
if edit2.Text='5' then
a:=(31+28+31+30+s-1) mod 7;
if edit2.Text='6' then
a:=(31+28+31+30+31+s-1) mod 7;
if edit2.Text='7' then
a:=(31+28+31+30+31+30+s-1) mod 7;
if edit2.Text='8' then
a:=(31+28+31+30+31+30+31+s-1) mod 7;
if edit2.Text='9' then
a:=(31+28+31+30+31+30+31+31+s-1) mod 7;
if edit2.Text='10' then
a:=(31+28+31+30+31+30+31+31+30+s-1) mod 7;
if edit2.Text='11' then
a:=(31+28+31+30+31+30+31+31+30+31+s-1) mod 7;
if edit2.Text='12' then
a:=(31+28+31+30+31+30+31+31+30+31+30+s-1) mod 7;
if a=0 then
label1.Caption:='星期天'
else if
a=1 then
label1.Caption:='星期一'
else if
a=2 then
label1.Caption:='星期二'
else if
a=3 then
label1.Caption:='星期三'
else if
a=4 then
label1.Caption:='星期四'
else if
a=5 then
label1.Caption:='星期五'
else if
a=6 then
label1.Caption:='星期六';
end;
说白了就是输入月份和日期,输出星期。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值