Files
python/C++专题课程/历年试题与资料/蓝桥杯2018年试题C++/2.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

31 lines
529 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include<bits/stdc++.h>
using namespace std;
/*判断某年是否为闰年*/
bool Runyear(int i) { //2004,2000是闰年,1900不是闰年
if((i%4==0&&i%100!=0)||i%400==0)
return true;
else
return false;
}
/*统计两个年份之间的总天数*/
int count(int m,int n) {
int sumday=0;
for(; m<=n; m++) {
if(Runyear(m))
sumday+=366;
else
sumday+=365;
}
return sumday;
}
int main() {
int s=count(1901,2000);
cout<<"总天数为:"<<s<<endl;
cout<<"除7循环数"<<s/7<<endl;
cout<<"除7余数为:"<<s%7<<endl;
}