错了求debug,禁止回复无意义内容
查看原帖
错了求debug,禁止回复无意义内容
372653
yaozhijiandeyeye楼主2020/10/28 21:47

https://nanti.jisuanke.com/t/T3247

#include<bits/stdc++.h>
using namespace std;
int day1[100]={0,31,28,31,30,31,30,31,31,30,31,30,31},day2[100]={0,31,29,31,30,31,30,31,31,30,31,30,31},year;
bool pd(int year)
{
    if(year%100!=0&&year%4==0)
    return 1;//返回1代表是质数
    else if(year%400==0&&year%100==0)
    {
        return 1;
    }
    else
        return 0;
}
int main()
{
    freopen("saturday.in","r",stdin);
    freopen("saturday.out","w",stdout);
    ios::sync_with_stdio(false);
    cin>>year;
    int ans[10001];
    memset(ans,0,sizeof(ans));
    int x=4+1;
    for(int y=1998;y<=9999;y++)
    {
        int pdf=pd(y);
        if(pdf==0)
        for(int month=1;month<=12;month++)
        {
            for(int day=1;day<=day1[month];day++)
            {
                x=x%7+1;
                if(x==6&&day==13)
                {
                    ans[y]++;
                }
            }
        }
        else
        for(int month=1;month<=12;month++)
        {
            for(int day=1;day<=day2[month];day++)
            {
                x=x%7+1;
                if(x==6&&day==13)
                {
                    ans[y]++;
                }
            }
        }
    }
    cout<<ans[year]<<"\n";
}
2020/10/28 21:47
加载中...