c语言---万年历(大一时的课程设计)

上传人:第*** 文档编号:34610335 上传时间:2018-02-26 格式:DOC 页数:23 大小:156.50KB
返回 下载 相关 举报
c语言---万年历(大一时的课程设计)_第1页
第1页 / 共23页
c语言---万年历(大一时的课程设计)_第2页
第2页 / 共23页
c语言---万年历(大一时的课程设计)_第3页
第3页 / 共23页
c语言---万年历(大一时的课程设计)_第4页
第4页 / 共23页
c语言---万年历(大一时的课程设计)_第5页
第5页 / 共23页
点击查看更多>>
资源描述

《c语言---万年历(大一时的课程设计)》由会员分享,可在线阅读,更多相关《c语言---万年历(大一时的课程设计)(23页珍藏版)》请在金锄头文库上搜索。

1、#include #include #include #include #define leap(i) (i%400=0|i%4=0&i%100!=0)/*判断是否为闰年*/#define main_printf printf(S:上一月 F:下一月 E:下一年 D:上一年n空格键:手动输入 Backspace:返回系统时间nESC:退出 t 回车键: 开启日历n)/*操作提示*/#define days(year,month) (month=4|month=6|month=9|month=11)?30:( (month!=2)?31:(year%400=0|year%4=0&year%100

2、!=0)?29:28)/*判断一个月有多少天*/#define head_place (timeinfo-tm_wday-(timeinfo-tm_mday%7-1)=0)?(timeinfo-tm_wday-(timeinfo-tm_mday%7-1):(timeinfo-tm_wday+(7-timeinfo-tm_mday%7+1)/*计算当月的头一天为星期几*/#define type_time time_t nowtime;struct tm *timeinfo;/*定义时间类型*/#define get_time (time( &nowtime ),timeinfo = local

3、time( &nowtime )/*获得时间信息*/#define update_time ( now.day=timeinfo-tm_mday , now.month=timeinfo-tm_mon+1 , now.year=timeinfo-tm_year+1900) /*更新当前时间*/ struct date /*时间结构体 */short year;short month;short day;now, /*当前 的 时间 */check; /*查看 的 时间*/char move_relate13=0, 3,0,3, 2,3,2, 3,3,2, 3,2,3; /每个月的头一天与下个月

4、的头一天的水平距离/#/#void input()/-输入需要查看的月份char inspect; /用于检查是否正确录入printf( -请输入需要查看的日期 : 4位年份-2位月份 nn-例如: %04d-%02dnn,now.year,now.month);/=/=循环, 直到正确录入为止= while( rewind(stdin),(scanf(%4d-%2d%c,&check.year,&check.month,&inspect)!=3) | (check.year10000)|(check.month12)| inspect!=10)printf(请以正确的格式输入 ,如:%04d

5、-%02d ( 00) for(i=now.year;i2move=(1)*(months/12) + tally; /每过一个非闰年,同一个月的头一天向后移一位 for(i=0;i2/减去未涉及2月份的闰年,每包含一个闰年需向前推进一位 if( now.month0;i-)move-=move_relate (now.month-i=1)?now.month-i:12+(now.month-i) ; /计算剩余各月份头一天的偏移总和move+=head_place;move%=7; return (move=0)?move:7+move; /#/#void output(int start_

6、place)/-/输出需要查看的月份int i,j,n,under_n;int record=7;int day=days(check.year,check.month); /判断该月所含有的天数;type_time; /定义时间类型 get_time; /获得时间信息/=/=标题 & logo=system(cls);printf(万年历 。 当前系统时间:%d-%d-%d .-. .-.n . ._ |/ :.-,n tm_year+1900,timeinfo-tm_mon+1,timeinfo-tm_mday); printf( 显示时间:%5d年-%02d月 / ./ /n,check

7、.year,check.month);printf(t%8s%8s%8s%8s%8s Fri-._.;-;- _ /n,Sun,Mon,Tue,Wed,Thu); printf(t=/ /| -. /(nt - -.- |_.-nt);/= /=首行与其下标识的输出=for(i=0,n=1;i=start_place) /循环到 头一天的星期 才开始 输出 日期printf(%8d,n+);continue;printf(t); printf( _nt); /首行输出完毕,换行,附带残余logo 图案for(i=0,under_n=1;i=start_place) /循环到 头一天的星期 才开

8、始 计算 日期if(under_n+)=timeinfo-tm_mday) /当前计算的日期与系统日期相同,则输出标记printf(%8s,(o); else /否则以空白代替printf(t); continue;printf(t); printf(nt); /当前计算行结束,换行/=/=剩余行与其下标识的输出=for(i=0;ntm_mday?(o):t) ); /*当前计算的日期与系统日期相同,则输出标记;否则以空白代替*/record+;/记录 控制输出格式对齐 if(recordtm_mday!=now.day|flag=1) /日期变化 或 第一次进入循环,则刷新输出 flag=0

9、; /以后不能再通过flag进入循环update_time; /刷新当前时间信息 check=now; /查看当前时间信息 output(head_place);printf(n日历模式中 ,需要退出请点右上角的叉叉.nttttt详细时间:);printf(%04d年-%02d月-%02d日 %02d:%02d:%02d,timeinfo-tm_year+1900,timeinfo-tm_mon+1,timeinfo-tm_mday,timeinfo-tm_hour,timeinfo-tm_min,timeinfo-tm_sec);printf(bbbbbbbbbbbbbbbbbbbbbbbbb);switch(timeinfo-tm_sec) /每十秒 变换 一次颜色case 0 :system(color 0a);break;case 10:system(color 0e);break;case 20:system(color 0b);break;case 30:system

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号