资源描述:
《安徽工业大学软件工程实验报告.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、《软件工程》实验报告姓名:胡成柱学号:129074044班级:计算机科学与技术122指导老师:周兵日期:2015年05月一.实验目的1.能按照软件工程的思想,采用面向过程的方法开发出一个小型软件系统。142.在软件系统开发过程中,能综合利用一门编程语言和软件工程等多门课程的知识。3.培养良好的软件开发习惯,了解软件企业文化。4.掌握结构化数据流分析技术。5.掌握结构化程序设计的基本概念与技术,并且养成良好的编码风格。6.掌握单元测试的一般步骤及技术。7.掌握集成测试的一般步骤和技术。一.实验内容1.软件需
2、求分析①、功能需求分析·输入一个年份(1-3000),然后显示12个月的月历·能解决闰年和平年问题·能输出显示结果②、运行需求分析·操作系统:Windows9x,Windows2000,WindowsXP及更高版本③、数据流图是否闰年确定年份开始信息开始信息年份显示其他月份显示12月错误显示表头计算1月1日检查输入年份任意键年份年份非法显示2月显示1月软件结构图:main14setinit()output()inputyear()checkinput()setinfo()printmonth()print
3、head()isleap()1.软件设计与编码#include#include#include#include#definefirstdayof11/*定义第一年的第一天,星期日=7*/#definegap""/*setgapbetweennumbersofdates*/#definedent""/*setrightmargin.*/structinfo{intmonth;intfirstdayofmonth;intdaysofmon
4、th;intleap;}monthinfo;intcheckinput(void);intinputyear(void);intisleap(inty);voidoutput(structinfo);voidprinthead(structinfo);voidprintmonth(structinfo);structinfosetinit(int);structinfosetmonthinfo(structinfo);14/*这个作用是判断年,如果是闰年,return1,否则return0*/intisl
5、eap(inty){return((y%4==0&&y%100!=0)
6、
7、y%400==0);}/*Thismoduleistoacceptinputyear()andcheckifitiscorrect.ifitiscorrectitreturnintyear,otherwiseaskuserreenter*/intcheckinput(void){inty;do{y=inputyear();if(y<1
8、
9、y>3000){printf("输入错误!。");y=0;}}while(y<1);
10、returny;}/*Thisfunctionistoaccepttheinputyear,ifitistheinteger,itreturnsit,otherwiseitreturn-1*/intinputyear(void){chars[80];inti,y;y=-1;printf("请输入年份(1-3000):");for(i=0;i<80;++i){14s[i]=getchar();if(s[i]==27)exit(0);if(s[i]==10)break;}for(i=0;i<80;++i){i
11、f(s[i]==10)break;elseif(!isdigit(s[i]))returny;}y=atoi(s);returny;}/*Thismoduleistoacceptmonthinfo,andprintthewholeyearcalender.*/voidoutput(structinfomonthinfo){charch;do{printhead(monthinfo);printmonth(monthinfo);printf("按任意键显视下一月,按Esc键退出.");ch=getcha
12、r();if(ch==27)exit(0);monthinfo=setmonthinfo(monthinfo);}while(monthinfo.month<13);}/*Thismoduleistoacceptmonthinfo,amdprintmonthlyheadlike"一月"*/voidprinthead(structinfomonthinfo){char*ss;printf("%s",dent);14switch(