c语言课程设计报告----万年历系统.doc_第1页
c语言课程设计报告----万年历系统.doc_第2页
c语言课程设计报告----万年历系统.doc_第3页
c语言课程设计报告----万年历系统.doc_第4页
c语言课程设计报告----万年历系统.doc_第5页
已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论