操作代码:
#include<iostream>
using namespace std;
int main()
{
int y,m,d,total=0,i;
int db[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
cout<<"请输入年月日并以空格分隔:";
cin>>y>>m>>d;
if((y%4==0&&y%100!=0)||(y%400==0))
{
cout<<y<<"年是闰年"<<endl;
for(i=0;i<m-1;i++)
{
total+=db[1][i];
}
}else
{
cout<<y<<"年是平年"<<endl;
for(i=0;i<m-1;i++)
{
total+=db[0][i];
}
}
total+=d;
cout<<"您输入的时期"<<y<<"年"<<m<<"月"<<d<<"日"<<"是这一年中的第"<<total<<"天\n";
return 0;
}
运行界面: