安徽工业大学软件工程实验报告Word文件下载.doc

上传人:b****9 文档编号:13025531 上传时间:2022-10-02 格式:DOC 页数:14 大小:353.27KB
下载 相关 举报
安徽工业大学软件工程实验报告Word文件下载.doc_第1页
第1页 / 共14页
安徽工业大学软件工程实验报告Word文件下载.doc_第2页
第2页 / 共14页
安徽工业大学软件工程实验报告Word文件下载.doc_第3页
第3页 / 共14页
安徽工业大学软件工程实验报告Word文件下载.doc_第4页
第4页 / 共14页
安徽工业大学软件工程实验报告Word文件下载.doc_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

安徽工业大学软件工程实验报告Word文件下载.doc

《安徽工业大学软件工程实验报告Word文件下载.doc》由会员分享,可在线阅读,更多相关《安徽工业大学软件工程实验报告Word文件下载.doc(14页珍藏版)》请在冰豆网上搜索。

安徽工业大学软件工程实验报告Word文件下载.doc

·

输入一个年份(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

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 纺织轻工业

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1