![C语言课程设计报告-万年历_第1页](http://file1.renrendoc.com/fileroot_temp2/2021-2/22/1aec1cd5-9695-4e7a-bc63-b99a0f2c3750/1aec1cd5-9695-4e7a-bc63-b99a0f2c37501.gif)
![C语言课程设计报告-万年历_第2页](http://file1.renrendoc.com/fileroot_temp2/2021-2/22/1aec1cd5-9695-4e7a-bc63-b99a0f2c3750/1aec1cd5-9695-4e7a-bc63-b99a0f2c37502.gif)
![C语言课程设计报告-万年历_第3页](http://file1.renrendoc.com/fileroot_temp2/2021-2/22/1aec1cd5-9695-4e7a-bc63-b99a0f2c3750/1aec1cd5-9695-4e7a-bc63-b99a0f2c37503.gif)
![C语言课程设计报告-万年历_第4页](http://file1.renrendoc.com/fileroot_temp2/2021-2/22/1aec1cd5-9695-4e7a-bc63-b99a0f2c3750/1aec1cd5-9695-4e7a-bc63-b99a0f2c37504.gif)
![C语言课程设计报告-万年历_第5页](http://file1.renrendoc.com/fileroot_temp2/2021-2/22/1aec1cd5-9695-4e7a-bc63-b99a0f2c3750/1aec1cd5-9695-4e7a-bc63-b99a0f2c37505.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、课程设计题目:万年历实验题目:万年历程序的编写实验目的:综合运用所学的C语言知识解决一个比较实际的简单问题,侧重对数组、函数、指针、结构体和文件等相关内容的综合应用, 使同学们能进一步熟悉掌握 C语言的基本语法,进一步提升自 己的编程能力并逐步培养编程思维,进而不断提高同学们解决问 题的能力,并为以后的语言学习打下良好的基础。实验要求:万年历设计主要功能包括:1查询某年某月每一天对应星期几。2、可以查询某年某月的上个月或是下个月的日历情况。3、查询某年某月某日是这一年的第几天,并查询改天 是星期几。4、判断该年是闰年还是平年,判断这一年的生肖。实现思路(要求有文字描述,并画出流程图):定义 S
2、=O;c=O该天使星期几及该月和上下月的情况实现过程(要求有文字说明实现的过程,并对相应的代码添加注释):见程序(程序见后)后的解析。00运行时只要你输入年月日,你要的星系都会显示出来;如果想继续输入日期的话,只需按y就可以,祥结束按n就可以结束。实验总结(分析程序的得与失):得:通过这次程序设计,更使我了解了编程序的严谨性,每个问题,每个不走都得有依据,不得盲目乱造,同时也让我获得了一点 编写简单程序的能力,使自己平时在理论课中很多部明白的东 西明白了好多,学会了好多语句的用法,比如会用y or n 来决定程序是否要继续;怎么控制输出格式等等。总之在这次 程序设计中我学到了很多。失:在编程序
3、过程中有些函数的用法不怎么会用,偶尔会落下写简单的东西。如, ;等;同时在编写输出上下个情况及判断 程序是否要继续的程序上花费了好多时间;函数的声明、调用 既然不清楚,感到很惭愧。实验的过失就是成功的阶梯,在过 失中我也学到很多。心得体会:我体会到了编程序的严谨性,也觉得如果我们要是熟悉课本所讲的内容,不怕麻烦,坚持不懈,我们一定可以将它实现的。要有耐心,有时候很多的错误就是一个地方引起的,只要认真 检查,一定能突破的,所以在以后的编程序是要细心,有耐心, 人不断调试程序,直至最后成功。#in cludestructII定义包含年月日数组结构体int year;int mon th;int d
4、ay;date;int ma in ()/ 主函数void prin t( in t, in t);int dobb(i nt);int date1(i nt,i nt,i nt);int rili();rili();return 0;函数的声明函数的声明 /函数的声明/函数的声明/函数的调用int rili()/定义函数int days;/定义整型变量int a,b;/定义整型变量char乙 /定义字符变量prin tf(+nn);/输出头的格式prin tf(万年历 nn ”);prin tf(+n); printf(” 功能有:n); printf(t);printf(1.查询某年某月某
5、天对应星期几;nt2.查询某年某月上下个月情况;nt3显示该日子是该年的第几天,并查询改天星期几;nt4.判断该年是平年还是闰年以及生肖等。n);printf(&+&n );pr intf(请输入年月日:);scanf(%d,%d,%d,&date.year,&date.month,&date.day);/ 输入年月曰switch(date.mo nth)/计算第几天的case 1: days=date.day;case 2: days=date.day+31;case 3: days=date.day+59;case 4: days=date.day+90;case 5: days=date
6、.day+120;case 6: days=date.day+151;case 7: days=date.day+181;case 8: days=date.day+212;case 9: days=date.day+243;case 10: days=date.day+273;case 11: days=date.day+304;case 12: days=date.day+334;break; break; break; break; break; break; break; break; break; break; break; break;days+;if(date.year%4=0&
7、date.year%100!=0 )| date.year%400=0)&date.mo nth=3) printf(%d 月 %d 日是 %d 的第 %d 天。n,date.month,date.day,date.year,days); if(date.year%4=0&date.year%100!=0)|date.year%400=0)/ 判断平闰年的语句prin tf(%d 是闰年。n,date.year);输出平闰年的elseprin tf(%d 是平年。n,date.year);if(date.year=2013)/判断2013年后生肖的语句a=(date.year-2013)%12
8、;switch(a)case 0:prin tf(%d是蛇年。n ”,date.year);break;case 1:prin tf(%d是马年。n ”,date.year);break;case 2:prin tf(%d是羊年。n ”,date.year);break;case 3:prin tf(%d是猴年。n ”,date.year);break;case 4:prin tf(%d疋鸡年。n ”,date.year);break;case 5:prin tf(%d是狗年。n ”,date.year);break;case 6:prin tf(%d是猪年。n ”,date.year);br
9、eak;case 7:prin tf(%d是鼠年。n ”,date.year);break;case 8:prin tf(%d是牛年。n ”,date.year);break;case 9:prin tf(%d是虎年。n ”,date.year);break;case 10:prin tf(%d是兔年。n ”,date.year);break;case 11:prin tf(%d是龙年。n ”,date.year);break;else b=(2013-date.year)%12;switch(b)/判断2013年前生肖的语句case 0:prin tf(%d是蛇年。n ”,date.year
10、);break;case 1:prin tf(%d是龙年。n ”,date.year);break;case 2:prin tf(%d是兔年。n ”,date.year);break;case 3:prin tf(%d是虎年。n ”,date.year);break;case 4:prin tf(%d是牛年。n ”,date.year);break;case 5:prin tf(%d是鼠年。n ”,date.year);break;case 6:prin tf(%d是猪年。n ”,date.year);break;case 7:prin tf(%d是狗年。n ”,date.year);brea
11、k;case 8:prin tf(%d疋鸡年。n ”,date.year);break;case 9:prin tf(%d是猴年。n ”,date.year);break;case 10:prin tf(%d是羊年。n ”,date.year);break;case 11:prin tf(%d是马年。n ”,date.year);break;/dobb( date .y ear);调用函数date1( date.year, date.m on th,date.day);调用函数prin t(date.year,date.m on th);/ 调用函数prin tf(co nti nu eY/N
12、.);/ 是否还要继续输入日期getchar();z=getchar(); if(z=y|z=Y) rili(); if(z= n|z=N) getchar(); return 0;/判断是/调用函数/判断不是结束void prin t(i nt year,i nt mon th)pri nt 函数的定义int i,j, n,leap,days,k,co unt;leap=dobb(year);/函数调用及赋值days=date1(year,m on th-1,1);/printf(%d 年n,year);for(i=mo nth-1;i=mo nth+1;i+)输出上下月的情况if(i12)
13、 pri ntf(%3d 月份 n,i-12);下年的 1 月if(i0&i13) prin tf(%3d月份 n ,i);/ 本年的月份prin tf(n);prin tf(t);printf(%-8s%-8s%-8s%-8s%-8s%-8s%-8sn,日,二,三,四,五,六);输出格式if(days=7)/控制输出的个数days=0;else n=days;prin tf(t);for(j=1;j=8*days;j+)/控制输出的日期对齐printf();switch(i)case 0:case 1:case 3:case 5:case 7:case 8:case 10:case 12:c
14、o un t=31;break;case 4:case 6:case 9:case 11:co un t=30;break;case 2:if(leap)count=29;2 月不同情况的判断else coun t=28;break;for(k=1;k=count;k+)/逐渐输出每月的日期prin tf(%-8d,k);n+;if(n=7)pri ntf(n);pri ntf(t); n=0;pri ntf(nn);days=n;int dobb(i nt year)/判断年份的类型函数的定义if(date.year%4=0&date.year%100!=0|(date.year%400=0)return(1); / 闰年输出 1else return(O);平年输出 0int date1(i nt year,i nt mo nth,i nt day)date1 函数的定义int leap,c n=0,sum;leap=dobb(year); / 调用函数switch(m on th-1)case 11: cn+=30;case 10: cn+=31;case 9: cn+
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024标准借款合同书
- 部编版九年级上册语文《艾青诗选》知识点和练习
- 2024版回迁房贷款合同
- 2024有孩子的离婚协议范文
- 父母赠与儿媳房产合同(2024版)
- 集装箱运输的合同(2024版)
- 大学社团面试的自我介绍范文(13篇)
- 端午节国旗下讲话小学
- 大学期末总结与反思大学期末的总结
- 2023年融资担保行业市场环境分析
- 2023肺结节多学科微创诊疗中国专家共识(最全版)
- 口腔种植病历书写格式要求及病历模板
- 无效成本管理的意义
- 发电机失磁保护新判据的研究的开题报告
- 一汽解放十档变速箱课件
- 自贡市富顺县2022-2023学年四年级数学第二学期期末联考试题含解析
- 2022-2023学年广州市增城区数学四下期末质量检测试题含解析
- 林业基础知识考试复习题库(浓缩500题)
- 服务群众意识不强的问题整改措施集合4篇
- 国开2023年春《管理英语2》机考网考期末复习资料参考答案
- 机械原理课程设计高位自卸汽车的设计
评论
0/150
提交评论