%*c 读入时跳过一位,本题中即跳过"-";
#include<stdio.h> int run(int x) //判断闰年 { int f=0; if(x%4==0&&x%100!=0) f=1; if(x%400==0) f=1; return f; } int main() { int y,m,d,sum=0,i,j,k,day=0; int a[12]={31,28,31,30,31,30,31,31,30,31,30,31}; scanf("%d%*c%d%*c%d",&y,&m,&d); for(i=y+1;i<2013;i++) //从输入的年份到2013中的整年份 { if(run(i)==1) sum+=366; else sum+=365; } for(i=0;i<m-1;i++) day+=a[i]; day+=d; //输入的是那一年的第几天 if(y!=2013) //年总天数减去那天的天数加上2013的3.9之前 { if(run(y)==0&&m<=2) //若与闰年二月有关则366 sum+=366-day+68; else sum+=365-day+68; } if(y==2013) sum=68-day; printf("%d\n",sum); return 0; }
时间: 2024-10-26 23:48:59