C语言万年历设计报告
C语言课程
设计报告
题目:编写万年历系统第2章 需求分析
第3章 概要设计
第4章 源程序清单
执行结果
1
2)显示当前日月历
3)显示具体日期信息
第6章 程序问题调试与课程设计心得
第1章设计目的
设计目的(实验要求):
1.模仿现实生活中的挂历.
(显示出日及对应的星期几).
,系统自动翻页到下一月.
菜单选择界面可通过下面所示函数时现;
主要思路:
通过while语句与swich…case以及if条件语句实现菜单的循环功能和不同选项的功能实现。
闰年与平年的判断:
代码如下:
void main()
{
int year,month,day,a,b;
while(1)
{
printf("\n\n\n\n");
printf(" **********************************************************\n\n");
printf(" * * \n");
printf(" Welcome to enter calendar system \n");
printf(" * * \n\n");
printf(" **********************************************************\n\n\n");
printf(" 1 The month of current date 2 Date 3 Exit\n");
printf(" please import your choose<1~3>,press Enter to define: ");
scanf("%d",&b);
switch(b)
{
case 1:
printf("\n Please import the year,month and day which you want to check,the year,month and day separation by blank space: ");
scanf("%d%d%d",&year,&month,&day);
a=x3(year,month,1);
if(a==0)
{
printf("Error!Please import again.\n");
break;}
yueli(year,month,day);
break;
case 2:
printf("\n Please import the year,month and day which you want to check,the year,month and day separation by blank space: ");
scanf("%d%d%d",&year,&month,&day);
a=x3(year,month,day);
if(a==0)
{
printf("Error!Please import again.\n");
break;}
rili(year,month,day);
break;
case 3:
exit(0);
default:
printf("Error!Please import again.\n\n");
}
}
2.闰年的判断:
计算所输入的年份是否可被4整除,若不能被整除,为平年。若可被4整除,计算此年份能否被100整除,不能被100整除则为闰年。既能被4整除,也能被100整除的年份,若也能被400整除,则为闰年,否则为平年。闰年366天,平年365天
代码:
int runnian(int year)
{
if(year%4==0&&year%100!=0||year%400==0)
return 1;
else
return 0;
}
3.判断某月的天数;
通过函数:
int day1(int year,int month)
{
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
若为闰,则二月为29天。
第4章