1 #include <stdio.h> 2 #include <stdbool.h> 3 int main() 4 { 5 int y,m,d; 6 while(scanf("%d%d%d",&y,&m,&d)){ 7 printf("%d ",dayOfYear(y,m,d)); 8 } 9 return 0; 10 } 11 // 判断是否是闰年 12 bool isLeapYear(int inputYear){ 13 if((inputYear%4==0&&inputYear%100!=0)||inputYear%400==0){ 14 return true; 15 } 16 else {return false;} 17 } 18 int dayOfYear(int year,int month,int day){ 19 int day_of_year; 20 if(isLeapYear(year)){ 21 day_of_year=((275 * month)/9)-((month + 9)/12)+day-30; 22 }else{ 23 day_of_year=((275 * month)/9)-(((month + 9)/12)<<1)+day-30; 24 } 25 return day_of_year; 26 }
说明
:
21行的275暂未解决