C-study/03-1/1/1.c

25 lines
387 B
C
Raw Normal View History

2021-10-29 16:05:32 +00:00
#include<stdio.h>
int month2day(int year,int month){
int tmp[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
if (year % 4 == 0)tmp[1]++;
return tmp[month-1];
}
int main(){
int year,month,day;
printf("Input year, month, day: \n");
scanf("%d %d %d",&year,&month,&day);
for(;month>1;month--){
day += month2day(year,month);
}
printf("Days of year: %d",day);
return 0;
}