方法1(列举)
#include<stdio.h>
#include<math.h>
int main()
{
int a,b,c,n;
while(scanf("%d/%d/%d",&a,&b,&c)!=EOF){
if((a%4==0&&a%100!=0)||a%400==0)//闰年29天
{
switch (b) {
case 1:n=c;break;
case 2:n=1*31+c;break;
case 3:n=1*31+29+c;break;
case 4:n=2*31+29+c;break;
case 5:n=2*31+29+30+c;break;
case 6:n=3*31+29+30+c;break;
case 7:n=3*31+29+2*30+c;break;
case 8:n=4*31+29+2*30+c;break;
case 9:n=5*31+29+2*30+c;break;
case 10:n=5*31+29+3*30+c;break;
case 11:n=6*31+29+3*30+c;break;
case 12:n=6*31+29+4*30+c;break;}
printf("%d\n",n);}
else{
switch (b) {
case 1:n=c;break;
case 2:n=1*31+c;break;
case 3:n=1*31+28+c;break;
case 4:n=2*31+28+c;break;
case 5:n=2*31+28+30+c;break;
case 6:n=3*31+28+30+c;break;
case 7:n=3*31+28+2*30+c;break;
case 8:n=4*31+28+2*30+c;break;
case 9:n=5*31+28+2*30+c;break;
case 10:n=5*31+28+3*30+c;break;
case 11:n=6*31+28+3*30+c;break;
case 12:n=6*31+28+4*30+c;break;}
printf("%d\n",n);
}
}
return 0;
}
方法2