<pre name="code" class="cpp">#include <iostream>
using namespace std;
int sum(int,int,int);
int main()
{
int y,m,n,x;//y.m.n分别为年月日
cout<<"请输入年,月,日"<<endl;
cin>>y>>m>>n;
x=sum(y,m,n);
cout<<x<<endl;
return 0;
}
int sum(int y,int m,int n)
{
int r(int y);
int s=0;
for(int i=1; i<m; i++)
switch(i)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
s+=31;
break;
case 4:
case 6:
case 9:
case 11:
s+=30;
break;
case 2:
s+=r(y);
break;
}
s+=n;
return s;
}
int r(int y)
{
if((y%4==0&&y%100!=0)||y%100==0)
return 29;
else return 28;
}