fork download
  1. # include<stdio.h>
  2.  
  3. int main(){
  4. int y,m,d,days[]={0,31,28,31,30,31,30,31,31,30,31,30,31},total=0;
  5. printf("需要判断的时间(年,月,日):\n");
  6. scanf("%d,%d,%d",&y,&m,&d);
  7.  
  8. if ((y%4==0&&y%100!=0)||y%400==0)days[2]=29;
  9. for (int i=0;i<m;i++)
  10. total+=days[i];
  11. total+=d;
  12.  
  13. printf("这是%d年的第%d天",y,total);
  14. return 0;
  15. }
  16.  
Success #stdin #stdout 0.01s 5320KB
stdin
2025,5,20
stdout
需要判断的时间(年,月,日):
这是2025年的第140天