31 lines
529 B
C++
31 lines
529 B
C++
#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;
|
||
}
|
||
|
||
|
||
|