
开始想复杂了,竟然想要考虑1901年1月1日是星期几? 其实只需要计算一下有几个7就行了
#include<stdio.h>
#include<queue>
#include<math.h>
#include<map>
#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
using namespace std;
#define ll long long
bool check(int x)
{
if(x%400==0||x%100!=0&&x%4==0)
{
return 1;
}
return 0;
}
int main()
{
int ans=0;
for(int i=1901;i<=2000;i++)
{
if(check(i))
{
ans+=366;
}
else ans+=365;
}
printf("%d\n",ans/7);
}
本文介绍了一段C++代码,用于计算从1901年到2000年间闰年的总天数,通过判断平闰年的规则,得出结果并除以7得出每7年里有多少个完整周。
4115

被折叠的 条评论
为什么被折叠?



