看一下这个用c语言编的万年历

[复制链接]
查看11 | 回复0 | 2010-9-17 19:19:49 | 显示全部楼层 |阅读模式
帮我改一下这个用c语言编写的万年历程序,让它实现输入某年某月后再点击enter时系统自动翻到所查询月的下一月。
#include
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; //判断二月是29天还是28天
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 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;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行