本文主要是介绍打印日期【华中科技大学】,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目链接
#include<stdio.h>
int main(){int year,day; while(scanf("%d %d",&year,&day)!=EOF){int months1[13]={0,31,59,90,120,151,181,212,243,273,304,334};int months2[13]={0,31,60,91,121,152,182,213,244,274,305,335};int month=0;int leap=0;int days=0;if(year%400==0||(year%100!=0&&year%4==0))leap=1;for(int i=11;i>=0;i--)if((leap?months2[i]:months1[i])<day){ month=i;days=day-(leap?months2[i]:months1[i]);break;} printf("%4d-%.2d-%.2d\n",year,month+1,days);}
return 0;
}
这篇关于打印日期【华中科技大学】的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!