黑色星期五

题意

给出N年的一个周期,要求计算1900年1月1日至1900+N-1年12月31日中十三号落在周一到周日的次数


分析

先算出当前月份的天数,再看有没有到13号,有的话就加次数。


var
x,m,y,d,i,n,j:longint;
a:array[1..7]of longint;


procedure c(var m:longint);
begin
    d:=1;
    inc(m);
end;


begin
    readln(n);
    y:=1900;
    m:=1;d:=1;x:=1;i:=0;
    fillchar(a,sizeof(a),0);
    while i<n do
    begin
        inc(x);
        if x=8 then x:=1;
        case m of
        1,3,5,7,8,10,12:if d=31 then c(m) else inc(d);
        4,6,9,11:if d=30 then c(m) else inc(d);
        2:if (y mod 4=0)and(y mod 100<>0)or(y mod 400=0) then
          if d=29 then c(m) else inc(d) else
          if d=28 then c(m) else inc(d);
        end;
        if m=13 then
        begin
            m:=1;
            inc(y);
            inc(i);
        end;
        if d=13 then inc(a[x]);
    end;
    write(a[6],' ',a[7],' ');
    for i:=1 to 5 do
    write(a[i],' ');
end.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值