版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、软件工程实验报告 一 实验目的 1能按照软件工程的思想,采用面向过程的方法开发出一个小型软件系统。2在软件系统开发过程中,能综合利用一门编程语言和软件工程等多门课程的知识。 3培养良好的软件开发习惯,了解软件企业文化。 4掌握结构化数据流分析技术。 5掌握结构化程序设计的基本概念与技术,并且养成良好的编码风格。 6掌握单元测试的一般步骤及技术。 7掌握集成测试的一般步骤和技术。二 实验内容1 软件需求分析 、功能需求分析输入一个年份(1-3000),然后显示12个月的月历能解决闰年和平年问题能输出显示结果、运行需求分析 操作系统: Windows2000, Windows XP、win7及更高
2、版本显示一月确定闰年计算1月1日是否闰年显示表头开始信息年份检查输入年份年份年份非法开始信息显示二月任意键显示十二月任意键、数据流图软件结构图2 软件设计与编码#include #include #include #include #define firstdayof1 1 /* define the first day of first year. 星期日=7 */#define gap /* set gap between numbers of dates */#define dent /* set right margin. */struct info int month; int fi
3、rstdayofmonth; int daysofmonth; int leap; monthinfo; int checkinput(void);int inputyear(void);int isleap(int y);void output(struct info);void printhead(struct info );void printmonth(struct info);struct info setinit(int);struct info setmonthinfo(struct info );/* This fuction is to accept year, if it
4、is leap year, it return 1, otherwise return 0 */ int isleap(int y)/判断是否为闰年 return (y%4=0 & y%100!=0) | y%400=0);/是闰年返回1,不是返回0/* This module is to accept inputyear() and check if it is correct. if it is correct it return int year, otherwise ask user reenter */ int checkinput(void)/检查输入的年份是否符合要求 int y
5、; do y=inputyear(); if(y3000) printf(n输入错误!。nn); y=0; while(y1); return y; /* This function is to accept the input year, if it is the integer, it returns it, otherwise it return -1 */int inputyear(void) char s80;/定义一个字符串数组存放输入的年份字符串 ,字符串长度为80 int i, y; y=-1; printf(请输入年份(1-3000):); for(i=0;i80;+i) s
6、i=getchar(); if(si=27)/循环接受字符,并判断字符,若此字符等于esc,退出此次接受年份,循环到下一次接受 exit(0); if(si=10) break; for(i=0;i80;+i) if(si=10) break; else if(!isdigit(si)/不是数字,直接返回y=1,输出输入错误 return y; y=atoi(s); return y;/*This module is to accept monthinfo, and print the whole year calender. */void output(struct info monthin
7、fo) char ch; do printhead(monthinfo); printmonth(monthinfo); printf(按任意键显视下一月, 按Esc键退出. n); ch=getchar(); if(ch=27) exit(0); monthinfo=setmonthinfo(monthinfo); while(monthinfo.month13);/* This module is to accept monthinfo, amd print monthly head like一 月 */void printhead(struct info monthinfo) char
8、*ss; printf(%s,dent); switch(monthinfo.month) case 1: ss=一 月; break; case 2: ss=二 月; break; case 3: ss=三 月; break; case 4: ss=四 月; break; case 5: ss=五 月; break; case 6: ss=六 月; break; case 7: ss=七 月; break; case 8: ss=八 月; break; case 9: ss=九 月; break; case 10: ss=十 月; break; case 11: ss=十一 月; break
9、; case 12: ss=十二 月; printf( %s%s%s%snn,gap,gap,gap,ss);/* This module is to accept monthinfo, and print the numbered dates of the month. */void printmonth(struct info monthinfo) int i,j,k; printf(%s,dent); printf(一%s二%s三%s四%s五%s六%s日nn,gap,gap,gap,gap,gap,gap); printf(%s,dent); for(i=1;imonthinfo.fir
10、stdayofmonth;i=i+1) printf(%s ,gap); k=monthinfo.firstdayofmonth; for(j=1;j7) k=k-7; printf(nn%s,dent); ; k=k+1; printf(%2d%s,j,gap); printf(nn);/* This module is to accept the monthinfo, and set the monthinfo of next month. */ struct info setmonthinfo(struct info monthinfo) int m; monthinfo.firstda
11、yofmonth= (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 monthinfo.d
12、aysofmonth = 28; return monthinfo;/* This module is to initialize the monthinfo. */struct info setinit(int year) int i,days,total; struct info monthinfo; monthinfo.month=1;/第一月 monthinfo.firstdayofmonth=firstdayof1;/firstdayof1初始化为1 for(i=1;iyear;i=i+1)/从第一年到year,monthinfo累计 if(isleap(i) days=366; e
13、lse days=365 ; monthinfo.firstdayofmonth=(monthinfo.firstdayofmonth+days-1)%7+1;/元月一号 monthinfo.daysofmonth=31; monthinfo.leap=isleap(year); return monthinfo; void main() int year ; struct info monthinfo; year = checkinput(); monthinfo = setinit(year); output(monthinfo);3 单元测试 白盒测试 黑盒测试2015年三 总结1 实验内容总结实验内容总结实验过程中遇到的最大问题就是,不知道一年中的元月一号是星期几。结果上网查了公式才知道。实验时按照每个步骤进行,自己按照数据流图设计程序代码,定义结构体,虽然出现了一些问题,但通过上网的查询
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026 年妇科肿瘤手术围手术期专科护理课件
- 2026 年各类手术体位并发症预防护理措施
- 2026 年肿瘤 PICC 并发症预防护理实践课件
- 2026年内分泌科糖尿病基础护理科普教学
- 生产管理考试试题及答案
- 11.0C双基地感知关键技术研究与验证白皮书-(中文)
- 南京市2026~2027学年高三上学期开学模拟考试语文试题及参考答案
- 2026年s版小学毕业考试试题及答案解析
- 2026年城市公共自行车租赁系统方案
- 园林高级专业考试试题及答案解析
- 2026-2030中国戊烷80和和20行业市场发展趋势与前景展望战略分析研究报告
- 2026时尚产业现状报告
- GB 47834-2026晶体硅光伏组件和逆变器能效限定值及能效等级
- 泳池灯光安装调试施工方案及技术措施
- 2026年部编版二年级上册语文教材分析
- 2026年养老管理师考试试题及答案详解
- T-CECS 《多段多级AO除磷脱氮技术规程》
- 涟源市六亩塘镇招聘社区网格员备考题库附答案详解
- 2026年电商平台主播合作协议内容范本
- 20S515 钢筋混凝土及砖砌排水检查井
- 冠心病心绞痛临床诊疗指南(2025版)
评论
0/150
提交评论