这个程序咋不对呢??走过路过千万不要错过
#include"stdio.h"int len_of_month(int year,int month){
int month_days;
if(month==2)
{
if(is_leap_year(year))
month_days=29;
else month_days=28;}
else if(month==4||month==6||month==8|month==9||month==11) month_days=30;
else month_days=31;
return month_days;
}
int len_of_days(int year,int month,int date){
int total_days=0,n;
for(n=1,total_days=0;n<month;n++){
total_days+=len_of_month(year,n);
total_days+=date;}
return total_days;
}
int is_leap_year(int year)
{int leap;
if( ((0 == year%4)&&(0 != year%100)) ||(0 == year %400) ) leap=1;
else leap=0;
return leap;
}
int main(){
int year,month,date,days,n;
printf("input year-month-date:\n");
scanf("%d-%d-%d",&year,&month,&date);
days=len_of_days(year,month,date);
printf("%d/%d/%d/is%d/day in %d",year,month,date,days,year);
}
搞出来有点问题,运行之后days不对
[ 本帖最后由 a271885843 于 2012-1-5 20:33 编辑 ]