题解 | 计算日期到天数转换
#include <stdio.h> int main() { int year,mon,day=0; scanf("%d %d %d",&year,&mon,&day); int dat=31; int feb=0; int data=0; if(((year%4==0)&&(year%100!=0))||(year%400==0)) feb=29; else feb=28; for(int i=1;i<mon;i++) { if(i<9) { if(i%2==0) { if(i==2) { data+=feb; continue; } if(i==8) { data+=31; continue; } data+=30; } else { data+=31; } } else { if(i%2==0) data+=31; else data+=30; } } printf("%d",data+day); return 0; }