这个题跟打印日期是一个类型
#include <stdio.h>
int main(){
int count(int year,int month,int day);
int year,month,day;
printf(“输入年月日:\n”);
scanf("%d%d%d",&year,&month,&day);
int days=count(year,month,day);
printf("\n%d/%d/%d is %dth in this year",year,month,day,days);
return 0;
}
int count(int year,int month,int day){
int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int i,sum=0;
if((year%40&&year%100!=0)||(year%4000))
a[2]=29;
for(i=0;i<month;i++){
sum=sum+a[i];
}
sum=sum+day;
return sum;
}
输入年月日,输出该天是今年的第几天
最新推荐文章于 2024-06-16 21:43:45 发布