安徽工业大学软件工程实验报告Word文件下载.doc
- 文档编号:13025531
- 上传时间:2022-10-02
- 格式:DOC
- 页数:14
- 大小:353.27KB
安徽工业大学软件工程实验报告Word文件下载.doc
《安徽工业大学软件工程实验报告Word文件下载.doc》由会员分享,可在线阅读,更多相关《安徽工业大学软件工程实验报告Word文件下载.doc(14页珍藏版)》请在冰豆网上搜索。
·
输入一个年份(1-3000),然后显示12个月的月历
·
能解决闰年和平年问题
能输出显示结果
②、运行需求分析
操作系统:
Windows9x,Windows2000,WindowsXP及更高版本
③、数据流图
是否闰年
确定年份
开始信息
年份
显示其他月份
显示12月
错误
显示表头
计算1月1日
检查输入
任意键
非法
显示2月
显示1月
软件结构图:
main
setinit()
output()
inputyear()
checkinput()
setinfo()
printmonth()
printhead()
isleap()
2.软件设计与编码
#include<
stdio.h>
ctype.h>
stdlib.h>
math.h>
#definefirstdayof11
/*定义第一年的第一天,星期日=7*/
#definegap"
"
/*setgapbetweennumbersofdates*/
#definedent"
"
/*setrightmargin.*/
structinfo{
intmonth;
intfirstdayofmonth;
intdaysofmonth;
intleap;
}monthinfo;
intcheckinput(void);
intinputyear(void);
intisleap(inty);
voidoutput(structinfo);
voidprinthead(structinfo);
voidprintmonth(structinfo);
structinfosetinit(int);
structinfosetmonthinfo(structinfo);
/*这个作用是判断年,如果是闰年,return1,否则
return0*/
intisleap(inty)
{
return((y%4==0&
&
y%100!
=0)||y%400==0);
}
/*Thismoduleistoacceptinputyear()andcheckifitiscorrect.ifitis
correctitreturnintyear,otherwiseaskuserreenter*/
intcheckinput(void)
inty;
do{
y=inputyear();
if(y<
1||y>
3000)
{
printf("
\n输入错误!
。
\n\n"
);
y=0;
}
}while(y<
1);
returny;
}
/*Thisfunctionistoaccepttheinputyear,ifitistheinteger,itreturns
it,otherwiseitreturn-1*/
intinputyear(void)
chars[80];
inti,y;
y=-1;
printf("
请输入年份(1-3000):
"
for(i=0;
i<
80;
++i)
{
s[i]=getchar();
if(s[i]==27)
exit(0);
if(s[i]==10)
break;
++i)
if(s[i]==10)break;
elseif(!
isdigit(s[i]))
returny;
y=atoi(s);
/*Thismoduleistoacceptmonthinfo,andprintthewholeyearcalender.*/
voidoutput(structinfomonthinfo)
charch;
printhead(monthinfo);
printmonth(monthinfo);
按任意键显视下一月,按Esc键退出.\n"
ch=getchar();
if(ch==27)
exit(0);
monthinfo=setmonthinfo(monthinfo);
}while(monthinfo.month<
13);
/*Thismoduleistoacceptmonthinfo,amdprintmonthlyheadlike"
一月"
*/
voidprinthead(structinfomonthinfo)
char*ss;
printf("
%s"
dent);
switch(monthinfo.month)
{
case1:
ss="
;
case2:
二月"
case3:
三月"
case4:
四月"
case5:
五月"
case6:
六月"
case7:
七月"
case8:
八月"
case9:
九月"
case10:
十月"
case11:
十一月"
case12:
ss="
十二月"
}
%s%s%s%s\n\n"
gap,gap,gap,ss);
/*Thismoduleistoacceptmonthinfo,andprintthenumbereddatesofthe
month.*/
voidprintmonth(structinfomonthinfo)
inti,j,k;
printf("
一%s二%s三%s四%s五%s六%s日\n\n"
gap,gap,gap,gap,gap,gap);
for(i=1;
monthinfo.firstdayofmonth;
i=i+1)
{
printf("
%s"
gap);
}
k=monthinfo.firstdayofmonth;
for(j=1;
j<
=monthinfo.daysofmonth;
j=j+1)
if(k>
7)
k=k-7;
printf("
\n\n%s"
};
k=k+1;
%2d%s"
j,gap);
/*Thismoduleistoacceptthemonthinfo,andsetthemonthinfoofnextmonth.
*/
structinfosetmonthinfo(structinfomonthinfo)
intm;
monthinfo.firstdayofmonth=(monthinfo.firstdayofmonth+\
monthinfo.daysofmonth-1)%7+1;
monthinfo.month=monthinfo.month+1;
monthinfo.daysofmonth=30;
m=monthinfo.month;
if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
monthinfo.daysofmonth=31;
if(m==2)
{
if(monthinfo.leap)
monthinfo.daysofmonth=29;
else
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 安徽 工业大学 软件工程 实验 报告