这个挺难的 高手们 帮下忙啊 帮忙解释一下 每一句都要 ...thx~~~~~~

来源:百度知道 编辑:UC知道 时间:2024/06/20 11:09:27
#include <stdio.h>
int leap (int year)
{if(year%4==0&&year%100!=0||year%400==0)
return 1;
else return 0;
}
int days_month (int month,int year)
{
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
return 31;
if(month==4||month==6||month==9||month==11)
return 30;
if(month==2&&leap(year)==1) return 29;
else return 28;
}
int firstday(int month,int year)
{int w;
w=(1+2*month+3*(month+1)/5+year+year/4+year/400-year/100)%7+1;
return w;
}
main()
{int i,j=1,k=1,a,b,month,year;
printf("\n input month and year:\n");
scanf("%d%d",&month,&year);
b=days_month(month,year);
a=firstday (month,year);
printf(" Sun Mon Tue Wed Thu Fri Sat \n");
if(a==7)
{for(i=1;i<=b;i++)
{printf("%4d",i);
if(i%7==0)
{printf("\n");
}

#include <stdio.h>
//包含标准输入输出头文件
#include <conio.h>
//getch需要这个头文件
int leap (int year)
//leap函数:输入year输出1(是闰年),0(不是闰年)
{if(year%4==0&&year%100!=0||year%400==0)
//判断如果(year对4取余为0并且year对100取余不为0或者year对400取余为0)
return 1;
//返回1
else return 0;
//返回0
}
int days_month (int month,int year)
//返回具体year里具体month的天数
{
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
//判断如果(month为1,3,5,7,8,10,12)
return 31;
//返回31
if(month==4||month==6||month==9||month==11)
//判断如果(month为4,6,8,9,11)
return 30;
//返回30
if(month==2&&leap(year)==1) return 29;
//判断如果(month为2并且year为闰年)返回29
else return 28;
//否则返回28
}
int firstday(int month,int year)
//计算具体year里具体month的第一天为周几
// Sun Mon Tue Wed Thu Fri Sat
// 7 1 2 3 4 5 6
{int w;
//声明整数w
w=(1+2*month+3*(month+1)/5+year+year/4+year/4