




已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
中国矿业大学徐海学院软件开发基础实践报告姓 名: 李岳 学 号: 22110522 专 业: 计算机科学与技术 指导教师: 孙锦程 职 称: 讲师 2012 年 6 月 30 徐州姓名/学号:李岳 22110522 班级:计(中软)11-11、 程序来源:百度贴吧 c语言吧/f?kw=c%D3%EF%D1%D4 二、程序项目名称:万年历3、 程序原理:1、int days12 = 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31; 这是定义的关于每个月天数的数组,根据大小月以及二月分的特殊情况将每个月的天数最为数组中的元素存入数组当中。其中days1=28,是将闰年二月的天数28天作为初始元素存入。在经过theWeek函数后就可以给days1中存入正确的月天数。2、char *weeks7 =Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday; char *months12 = January, February, March, April, May, June, July, August, September, October, November, DeCember; 这两组数据都设计利用了指针定义的。这两个数组的作用是存入每个月,每个星期的地址。利用指针可以提高程序的可读性,可以更方便使用。四、程序功能: 1、输入年份,判断是否为闰年 2、输入年月日,判断改日为星期几 3、输入年份,打出12个月历,输入月份,打出该月的日历五、程序内容(输入输出): isLeap和theLeap函数的共同使用,一起判断出了输入年份是否为闰年的信息。 theCalendar/*打开相应的详情*/ ,details /*月历详情函数*/ ,printCalendar /*输出日期详情及表格*/,通过这三个函数可以将输入数据的具体信息通过完整日历的形式表示出来。六、数据流分析(定义的变量,类型,数组,类型,结构体):头文件:stdio.h /*/ conio.h /*/ stdlib.h /*/采用指针形式定义了*weeks和*months两组数组指针变量在程序中运用了大量的自定义函数,都涉及为了使程序更简介明了。其中有:isLeap/*判断是否为闰年*/theLeap/*输入输出改年是否为闰年的信息*/ Zeller/*判断星期的自定义函数*/ theWeek()/*对于输入的日期输出该天是星期几*/ printCalendar()/*输出日期详情及表格*/ details /*月历详情函数*/ theCalendar/*打开相应的详情*/ Menu()/*程序的主菜单*/ Select()/*按键的控制函数*/这些函数的定义极其相应的内部程序共同构筑起了这个万年历总程序。其中的isLeap函数是用来判断输入的年份是否为闰年,实现了预计功能的第一个方面;theWeek函数则是为了实现判断星期而编写的;printCalendar , details , theCalendar这三个函数的共同使用就能够完成第三个功能。七、程序代码分析(每个函数和代码模块的功能作用分析):1、总天数算法isLeap和theLeap函数的共同使用,一起判断出了输入年份是否为闰年的信息。判断一年是否为闰年的方法是:该年分而能被四整除但不能被100整除,或者是能被400整除。2、计算输入日期是星期几利用Zeller函数可以判断出星期,然后对于输入的日期可以通过theWeek() 函数对Zeller进行一次调用然后就可以输出相应的星期数。int Zeller(int year, int month, int day) /by theWeek(); printCalendar();/*判断星期的函数*/ int C, y, m, d, w; if( month = 0 ? w : w+7);void theWeek() /by Select();/*对于输入的日期输出该天是星期几*/ int year, month, day, w; printf(n); do printf(Please input the date(YYYY-MM-DD): ); scanf(%d-%d-%d, &year, &month, &day); if( isLeap( year ) ) days1 = 29; /是否闰年 else days1 = 28; while(!( (month 0 & month 0 & day = daysmonth - 1) ) ); w = Zeller(year, month, day); printf(nThis day %d-%02d-%02d is %s., year, month, day, weeksw); getch();3、对输入信心的汇总theCalendar/*打开相应的详情*/ ,details /*月历详情函数*/ ,printCalendar /*输出日期详情及表格*/,通过这三个函数可以将输入数据的具体信息通过完整日历的形式表示出来。void printCalendar(int year, int month) /by details(); theCalendar();/*输出日期详情及表格*/ int w, d; w = Zeller(year, month, 1); printf(%28s, monthsmonth - 1); printf(n -%02d-n, month); printf( SUN MON TUE WED THU FRI SATn); for(d = 0; d w; d+) printf( ); for(month-, d = 1; d =0 & month = 12); if(month != 0) printf(n); printf(Calendar %dn, year); printCalendar(year, month); if( getch() = 0) break; else break; void theCalendar() /by Select(); int year, month; printf(nPlease input the year: ); scanf(%d, &year); if( isLeap( year ) ) days1 = 29; /是否闰年 else days1 = 28; system(cls); printf(Calendar %dn, year); for(month = 1; month = 12; month+) printCalendar(year, month); printf(More details of each month ?Y/N); if( tolower(getch() = y ) details( year );八、控制流分析(源程序整体流程图):开始计算是否为闰年计算星期数按键1?按键2?按键3?输出是否为闰年输出星期数计算编辑接收到的数据输出具体月历按键0?是是是是计算是否为闰年计算星期数按键1?按键2?按键3?是是是计算是否为闰年计算星期数按键1?按键2?按键3?是是计算是否为闰年计算星期数按键1?按键3?是是结束 退出九、源代码优点,好处:程序中使用了大量的自定义函数,使程序简单明了,效率更高十、总结及心得体会: 这次“万年历系统设计”的课程设计不仅让我对C语言的熟悉程度上升到了另一个高度,更加熟练的运用C语言,而且在一定意义上对面向过程设计的理解更加深刻了。是我在编程路途上的一次质的飞跃。而且在处理非常规数据类型的运算的锻炼下,使我对编程语言有了一个新的认识。当看着一个具有图形界面的万年历的模型成品出现在自己面前时,心中有着无限感慨,原来编程也不是非常遥不可及的,原来在编程的趣味性中能让我学到更多有意思的知识十一、对源程序过程及方法、手段的改进建议: 在主菜单输入0后,显示:是否真的要退出(Y/N)? 如果输入Y 则退出程序 否则重新运行 Case 0: 后的代码改为 printf(nDo you want to Exit?(Y/N); con=getch(); if(con=y)|(con=Y) return; if(con=n)|(con=N) Exit(1);报告评分: 指导教师签字:源代码#include #include /getch(); tolower(); exit();#include /system();int days12 = 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31;char *weeks7 =Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday;char *months12 = January, February, March, April, May, June, July, August, September, October, November, December;bool isLeap(int year) /by theLeap(); theCalendar();/*判断是否为闰年*/ if(year%4 = 0 & year%100 != 0 | year%400 = 0) return 1; else return 0; void theLeap() /by Select();/*输入输出改年是否为闰年的信息*/ int year; printf(nPlease input the year: ); scanf(%d, &year); if( isLeap( year ) ) printf(nThe year %d is leap year., year); else printf(nThe year %d is not leap year., year); getch();int Zeller(int year, int month, int day) /by theWeek(); printCalendar();/*判断星期的自定义函数*/ int c, y, m, d, w; if( month = 0 ? w : w+7);void theWeek() /by Select();/*对于输入的日期输出该天是星期几*/ int year, month, day, w; printf(n); do printf(Please input the date(YYYY-MM-DD): ); scanf(%d-%d-%d, &year, &month, &day); if( isLeap( year ) ) days1 = 29; /是否闰年 else days1 = 28; while(!( (month 0 & month 0 & day = daysmonth - 1) ) ); w = Zeller(year, month, day); printf(nThis day %d-%02d-%02d is %s., year, month, day, weeksw); getch();void printCalendar(int year, int month) /by details(); theCalendar();/*输出日期详情及表格*/ int w, d; w = Zeller(year, month, 1); printf(%28s, monthsmonth - 1); printf(n -%02d-n, month); printf( SUN MON TUE WED THU FRI SATn); for(d = 0; d w; d+) printf( ); for(month-, d = 1; d =0 & month = 12); if(month != 0) printf(n); printf(Calendar %dn, year); printCalendar(year, month); if( getch() = 0) break; else break; void theCalendar() /by Select(); int year, month; printf(nPlease input the year: ); scanf(%d, &year); if( isLeap( year ) ) days1 = 29; /是否闰年 else days1 = 28; system(Cls); printf(Calendar %dn, year); for(month = 1; month = 12; month+) printCalendar(year, month); printf(More details of each month ?Y/N); if( tolower(getch() = y ) details( year );void Menu() /by main();/*程序的主菜单*/ system(cls); printf(1 -This year is leap year or notn); printf(2 -This day is which day of the weekn); printf(3 -The Calendar of this yearn); printf(0 -Exitnn); printf(Pleas
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 计算流体力学SOD激波管
- 设备维修协议书范文
- 表里的生物教案
- 江苏省盐城市射阳中学2025届高三下学期全真模拟(4)生物试卷(有答案)
- 财务会计实习心得(15篇)
- 表526班组安全技术交底表样板
- 广东省部分学校2024-2025学年高一下学期6月月考历史试题
- 幼儿园《春天的秘密》教学课件
- 财务会计沙盘实训心得体会5篇
- 民航地勤通 用服务培训教学课件
- 清华强基化学试题
- 2024-2030年中国机器人关节模组行业市场竞争态势及前景战略研判报告
- 实验室仪器设备等采购项目培训方案
- 三江学院辅导员考试试题2024
- UASB+SBR处理果汁废水设计说明书及图纸
- 华图教育:2024年国考面试白皮书
- 2024年海港区社区工作者招聘笔试冲刺题(带答案解析)
- 国开2024春专科《高等数学基础》形考任务1-4试题及答案
- T-JSIA 0002-2022 能源大数据数据目录指南
- 2024高校院长述职报告
- 化工催化与催化反应工程
评论
0/150
提交评论