回复 10楼 grmmylbs
我试了试,这两个都行
#include <stdio.h> int main() { int dayofmonth[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int day,month,year; printf("Input year,month,day:"); scanf("%d,%d,%d",&year,&month,&day); int i,total=day; for(i=1;i<month;i++) { total+=dayofmonth[i]; } if(year%400==0||(year%4==0&&year%100!=0)) { if(month>2) total+=1; } printf("It is the %dth day of the year\n",total); return 0; }
[此贴子已经被作者于2016-3-25 15:22编辑过]