#include<iostream>
using namespace std;
bool year(int y)//闰年返回yes,平年返回no
{
if(y%400==0||y%4==0&&y%100!=0)
return true;
else
return false;
}
int main()
{
int y,m,d;
int r[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int p[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
while(cin>>y>>m>>d)
{
int ans=0;
ans+=d;
if(year(y))//闰年
{
for(int i=m-1;i>=1;--i)
ans+=r[i];
}
else//平年
{
for(int i=m-1;i>=1;--i)
ans+=p[i];
}
cout<<ans<<endl;
}
return 0;
}
#include<iostream>
using namespace std;
bool year(int y)
{
if(y%400==0||y%4==0&&y%100!=0)
return true;//闰年
else
return false;//平年
}
int main()
{
int y,d;
int r[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int p[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
while(cin>>y>>d)
{
int ans=1;
if(year(y))
{
while(d>r[ans])//从一月份开始,先比较天数和当前月份的大小,天数<当前月份,说明答案就是当前月份
{
d-=r[ans];
ans++;
}
}
else
{
while(d>p[ans])
{
d-=p[ans];
ans++;
}
}
cout<<ans<<endl<<d<<endl;
}
return 0;
}
```
include[HTML_REMOVED]
using namespace std;
bool year(int y)//闰年返回yes,平年返回no
{
if(y%400==0||y%4==0&&y%100!=0)
return true;
else
return false;
}
int main()
{
int week[]={7,1,2,3,4,5,6};
int n,m;
cin>>n>>m;
int next=5;//2021-1-1是星期五
for(int i=n;i<=m;++i)
{
cout<<i<<”年:”<<next<<endl;
if(year(i))
{
next=week[(next+366)%7];
}
else
next=week[(next+365)%7];
}
return 0;
}
```