第几天?(hdu2005)
Posted Strugglinggirl
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第几天?(hdu2005)相关的知识,希望对你有一定的参考价值。
第几天那个代码模板可以保存起来。
#include<stdio.h> #include<math.h> #define PI 3.1415927 using namespace std; int main() { int year,month,day; char a,b,d; while(scanf("%d%c%d%c%d%c",&year,&a,&month,&b,&day,&d)!=EOF) { switch(month) { case 1: day=day; break; case 2: day=31+day; break; case 3: day=31+28+day; break; case 4: day=31+28+31+day; break; case 5: day=31+28+31+30+day; break; case 6: day=31+28+31+30+31+day; break; case 7: day=31+28+31+30+31+30+day; break; case 8: day=31+28+31+30+31+30+31+day; break; case 9: day=31+28+31+30+31+30+31+31+day; break; case 10: day=31+28+31+30+31+30+31+31+30+day; break; case 11: day=31+28+31+30+31+30+31+31+30+31+day; break; default: day=31+28+31+30+31+30+31+31+30+31+30+day; } if(month>2) { if(year%100==0) { if(year%400==0) { day=day+1; printf("%d\\n",day); } else { printf("%d\\n",day); } } else { if(year%4==0) { day=day+1; printf("%d\\n",day); } else { printf("%d\\n",day); } } } else printf("%d\\n",day); } }
以上是关于第几天?(hdu2005)的主要内容,如果未能解决你的问题,请参考以下文章