短代码.第几天
给定一个日期,输出这个日期是该年的第几天。输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成。对于每组输入数据,输出一行,表示该日期是该年的第几天。
也许这里只有y/100%4+y%4判断是否是闰年有点价值吧...
比如
1985/1/20
2006/3/12
输出
20
71
不多解释了...1985/1/20
2006/3/12
输出
20
71
main(y,m,d){while(scanf("%d/%d/%d",&y,&m,&d)==3){char s[]={0,1,-1,0,0,1,1,2,3,3,4,4};m--;d+=m*30+s[m],(y%400==0||y%100&&y%4==0)&&m>1&&d++;printf("%d\n",d);}}
int s[]={0,1,-1,0,0,1,1,2,3,3,4,4};main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+s[m]+!((y%400&&0==y%100||y%4)||m<2)))m--;}
int s[]={0,1,-1,0,0,1,1,2,3,3,4,4};main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+s[m]+!(y%400&&0==y%100||y%4||m<2)))m--;}
int s[]={0,1,-1,0,0,1,1,2,3,3,4,4};main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+s[m]+!(y/100%4||y%4||m<2)))m--;}
int s[]={0,1,-1,0,0,1,1,2,3,3,4,4};main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+s[m]+!(y/100%4+y%4||m<2)))m--;}
main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+"bcabbccdeeff"[m]-'b'+!(y/100%4+y%4||m<2)))m--;}
main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+"BCABBCCDEEFF"[m-1]-96+!(y/100%4+y%4||m<3)));}
main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+"XBCABBCCDEEFF"[m]-96+!(y/100%4+y%4||m<3)));}
main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+"XBCABBCCDEEFF"[m]-95-(y/100%4+y%4||m<3)));}
int s[]={0,1,-1,0,0,1,1,2,3,3,4,4};main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+s[m]+!((y%400&&0==y%100||y%4)||m<2)))m--;}
int s[]={0,1,-1,0,0,1,1,2,3,3,4,4};main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+s[m]+!(y%400&&0==y%100||y%4||m<2)))m--;}
int s[]={0,1,-1,0,0,1,1,2,3,3,4,4};main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+s[m]+!(y/100%4||y%4||m<2)))m--;}
int s[]={0,1,-1,0,0,1,1,2,3,3,4,4};main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+s[m]+!(y/100%4+y%4||m<2)))m--;}
main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+"bcabbccdeeff"[m]-'b'+!(y/100%4+y%4||m<2)))m--;}
main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+"BCABBCCDEEFF"[m-1]-96+!(y/100%4+y%4||m<3)));}
main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+"XBCABBCCDEEFF"[m]-96+!(y/100%4+y%4||m<3)));}
main(y,m,d){for(;~scanf("%d/%d/%d",&y,&m,&d);printf("%d\n",d+m*30+"XBCABBCCDEEFF"[m]-95-(y/100%4+y%4||m<3)));}
也许这里只有y/100%4+y%4判断是否是闰年有点价值吧...