1985/1/20 2006/3/12
20 71
#include<iostream>
using namespace std;
bool leapyear(int n)
{
if(n%4==0&&n%100!=0||n%400==0)
return 1;
else
return 0;
}
int main()
{
int year,mouth,day;
char ch1,ch2;
while(cin>>year>>ch1>>mouth>>ch2>>day)
{
int sum=0;
for(int k=1;k<mouth;k++)
{
if(k==1||k==3||k==5||k==7||k==8||k==10||k==12)
sum+=31;
else if(k==2)
{
if(leapyear(year))
sum+=29;
else
sum+=28;
}
else
sum+=30;
}
sum+=day;
cout<<sum<<endl;
}
return 0;
}
原文:http://blog.csdn.net/lsgqjh/article/details/44764217