|
本帖最后由 守护¥云 于 2010-7-11 12:57 编辑
额,,,,弄了大半个星期,还是没能改好,就是不能显示阴历,咳,,,,C这东西还真是讨厌。不过要是有人不嫌弃的话有用到可以拿去用下哈!
下面是主界面图
- #include<string.h>
- #include<dos.h>
- #include<time.h>
- #include<stdio.h>
- #include<bios.h>
- #include<stdlib.h>
- #include<conio.h>
- #define LEFT 0x4b00
- #define RIGHT 0x4d00
- #define ESC 0x011b
- #define ENTER 0x1c0d
- char *a[4]={"left","right","up","down"};/*设定上下左右按键数组*/
- int num=3000,key,year=2006;/*设定初始年份变量*/
- int i,j,first=3,w=30;/*设定变量、窗口变量*/
- char *month[12]={"Junuary","February","March","April","May","June","July","August","September","October","November","December"};
- int mon[12]={31,28,31,30,31,30,31,31,30,31,30,31};/*设定月份天数数组*/
- int fd[12]={0};/*定义按键数组、各年每月的天数及月分名称*/
- int getkey()
- {char lowbyte;
- int press;
- while(bioskey(1)==0)
- press=bioskey(0);
- lowbyte=press&0xff;
- press=press&0xff00+toupper(lowbyte);
- return(press);
- }
- void sch()
- {window(22,24,29,24);
- textbackground(GREEN);
- clrscr();
- textcolor(15);
- cprintf("\nSearch");}
- void sch_0()
- {window(22,24,29,24);
- textbackground(GREEN);
- clrscr();
- textcolor(128);
- cprintf("\nSearch ");} /*设定搜索窗口*/
- void backk()
- {window(32,24,36,24);
- textbackground(GREEN);
- clrscr();
- textcolor(15);
- cprintf("\nM1-4");}
- void backk_0()
- {window(32,24,36,24);
- textbackground(GREEN);
- clrscr();
- textcolor(128);
- cprintf("\nM1-4");} /*建1-4月份按键窗口*/
- void left()
- {
- window(39,24,43,24);
- textbackground(GREEN);
- clrscr();
- textcolor(15);
- cprintf("\nM5-8");}
- void left_0()
- {window(39,24,43,24);
- textbackground(GREEN);
- clrscr();
- textcolor(128);
- cprintf("\nM5-8");} /*建5-8月份按键窗口*/
- void right()
- {window(46,24,52,24);
- textbackground(GREEN);
- clrscr();
- textcolor(15);
- cprintf("\nM9-12");}
- void right_0()
- {window(46,24,52,24);
- textbackground(GREEN);
- clrscr();
- textcolor(128);
- cprintf("\nM9-12");} /*建9-12月份按键窗口*/
- void lun_()
- {window(55,24,60,24);
- textbackground(GREEN);
- clrscr();
- textcolor(15);
- cprintf("\ntime");
- }
- void lun_0()
- {window(55,24,60,24);
- textbackground(GREEN);
- clrscr();
- textcolor(128);
- cprintf("\ntime"); /*建系统时间按键窗口*/
- }
- void clock_()
- {window(63,24,68,24);
- textbackground(GREEN);
- clrscr();
- textcolor(15);
- cprintf("\nclock");
- }
- void clock_0()
- {window(63,24,68,24);
- textbackground(GREEN);
- clrscr();
- textcolor(128);
- cprintf("\nclock");}/*设定闹钟按键窗口*/
- }
- void iexit()
- {window(71,24,76,24);
- textbackground(GREEN);
- clrscr();
- textcolor(15);
- cprintf("\nExit");}
- void iexit_0()
- {window(71,24,76,24);
- textbackground(GREEN);
- clrscr();
- textcolor(128);
- cprintf("\nExit");} /*建退出按键窗口*/
- void jiance(int n)
- {switch(n)
- {case 0:sch_0();left();right();lun_();clock_();iexit();backk();break;
- case 1:backk_0();left();right();lun_();clock_();iexit();sch();break;
- case 2:left_0();right();lun_();clock_();iexit();sch();backk();break;
- case 3:right_0();left();lun_();clock_();iexit();sch();backk();break;
- case 4:lun_0();clock_();iexit();sch();backk();left();right();break;
- case 5:clock_0();iexit();sch();backk();left();right();lun_();break;
- case 6:iexit_0();left();right();lun_();clock_();sch();backk();break;
- default:exit(0);
- }
- } /*实现搜索、日期各窗口间的切换的函数*/
- void quzhi()
- {window(8,24,20,24);
- textbackground(2);
- clrscr();
- textcolor(BLACK);
- cscanf("%d",&year);
- }/*搜索输入年份窗口*/
- void month1_4()
- {
- for(i=0;i<2;i++)
- {window(2+i*w,3,29+w*i,11);
- textbackground(5);
- clrscr();
- textcolor(BLACK);/*设定1-4月份显示窗口*/
- cprintf(" %s\n",month);
- gotoxy(1,2);cprintf(" Mon Tue Wed Thu Fri Sat Sun");
- gotoxy(4*(fd-1)+1,3);
- for(j=1;j<=mon;j++)
- {cprintf("%3d ",j);
- }
- }
- for(i=2;i<4;i++)
- {window(2+(i-2)*w,13,29+w*(i-2),21);
- textbackground(5);
- clrscr();
- textcolor(BLACK);
- cprintf(" %s\n",month);
- gotoxy(1,2);cprintf(" Mon Tue Wed Thu Fri Sat Sun");
- gotoxy(4*(fd-1)+1,3);
- for(j=1;j<=mon;j++)
- {cprintf("%3d ",j);
- }
- }
- } /*1-4月份的窗口设置及计算函数*/
- void month5_8()
- {for(i=0;i<2;i++)
- {window(2+i*w,3,29+w*i,11);
- textbackground(5);
- clrscr();
- textcolor(BLACK); /*设定5-8月份显示窗口*/
- cprintf(" %s\n",month[i+4]);
- gotoxy(1,2);cprintf(" Mon Tue Wed Thu Fri Sat Sun");
- gotoxy(4*(fd[i+4]-1)+1,3);
- for(j=1;j<=mon[i+4];j++)
- {cprintf("%3d ",j);
- }
- }
- for(i=2;i<4;i++)
- {window(2+(i-2)*w,13,29+w*(i-2),21);
- textbackground(5);
- clrscr();
- textcolor(BLACK);
- cprintf(" %s",month[i+4]);
- gotoxy(1,2);cprintf(" Mon Tue Wed Thu Fri Sat Sun");
- gotoxy(4*(fd[i+4]-1)+1,3);
- for(j=1;j<=mon[i+4];j++)
- {cprintf("%3d ",j);
- }
- }
- } /*5-8月份的窗口设置及计算函数*/
- void month9_12()
- {for(i=0;i<2;i++)
- {window(2+i*w,3,29+w*i,11);
- textbackground(5);
- clrscr();
- textcolor(BLACK);/*设定9-12月份显示窗口*/
- cprintf(" %s\n",month[i+8]);
- gotoxy(1,2);cprintf(" Mon Tue Wed Thu Fri Sat Sun");
- gotoxy(4*(fd[i+8]-1)+1,3);
- for(j=1;j<=mon[i+8];j++)
- {cprintf("%3d ",j);
- }
- }
- for(i=2;i<4;i++)
- {window(2+(i-2)*w,13,29+w*(i-2),21);
- textbackground(5);
- clrscr();
- textcolor(BLACK);
- cprintf(" %s",month[i+8]);
- gotoxy(1,2);cprintf(" Mon Tue Wed Thu Fri Sat Sun");
- gotoxy(4*(fd[i+8]-1)+1,3);
- for(j=1;j<=mon[i+8];j++)
- {cprintf("%3d ",j);
- }
- }
- } /*9-12月份的窗口设置及计算函数*/
- void calendar(int year)
- {int x,cha;
- long day=0;
- window(1,2,80,22);
- textbackground(YELLOW);
- clrscr();/*设定年份显示窗口*/
- if(year<2007)
- {for(x=year;x<2007;x++)
- {if((x%4==0&&x%100!=0)||x%400==0)/*判断是否为润年*/
- day+=366;
- else day+=365;}
- cha=day%7;
- first=(7+1-cha)%7;
- if(first==0)first=7;
- }/*对星期的排*/
- if(year==2007)first=1;
- if(year>2007)
- {for(x=2007;x<year;x++)
- {if((x%4==0&&x%100!=0)||x%400==0)
- day+=366;
- else day+=365;}
- cha=day%7;
- first=(1+cha)%7;
- if(first==0)first=7;
- }
- if((year%4==0&&year%100!=0)||year%400==0)
- mon[1]=29;
- else mon[1]=28;/*判断是否为润年、确定二月份天数*/
- fd[0]=first;
- for(j=1;j<12;j++)
- {fd[j]=(fd[j-1]+mon[j-1])%7;
- if(fd[j]==0)fd[j]=7;}
- month1_4();}
- int GetMinute(char *s)
- {
- char *p;
- p = (char *)malloc(10);
- strcpy(p, s);
- while(*p != ':')
- {
- p++;
- }
- p++;
- return atoi(p);
- }
- void clock_1()
- {
- char s[10];
- int hour,minute;/*设定小时、分钟变量*/
- time_t t;
- struct tm *timeinfo;
- printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nplease input the time like [18:30]:\n\n\n\n\n\n\n\n\n\n\n");
- gets(s); /*显示请输入时间如[18:30]*/
- hour = GetHour(s);
- minute = GetMinute(s);
- while(!kbhit())/*设定按任意键退出*/
- {
- time(&t);
- timeinfo = localtime(&t);
- if(timeinfo->tm_hour < hour)continue;
- else if(timeinfo->tm_min < minute)continue;
- else
- {
- printf("Time is up!Wake up!\n\007"); getch();
- system("c: [url=file://\\she.wav]\\she.wav[/url]");
- main();
- }
- }
- }
- int GetHour(char *s)
- {
- char *p, *q;
- p = (char *)malloc(10);
- strcpy(p, s);
- q = p;
- while(*q != ':')
- {
- q++;
- }
- *q = '\0';
- return atoi(p);
- }
- void time_1()
- {
- struct date d; /*设置系统日期变量*/
- struct time t; /*设置系统时间变量*/
- while(!kbhit())
- {
- clrscr();
- gettime(&t); /*获取系统时间*/
- getdate(&d); /*获取系统日期*/
- printf("\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n Today is: %d.%d.%d \n",d.da_year,d.da_mon,d.da_day);
- printf(" \n\n The current time: %d:%d:%d \n\n\n\n\n\n\n\n\n\n\n\nplease press any key to exit!",t.ti_hour,t.ti_min,t.ti_sec);
- sleep(1);
- main();
- }
- } /*设置单独的系统时间窗口,运行后按任意键退出*/
- void jiance2(int n)
- {void nian(int year);
- switch(n)
- {case 0:getch( );quzhi();calendar(year);nian(year);break;
- case 1:month1_4();break;
- case 2:month5_8();break;
- case 3:month9_12();break;
- case 4:time_1();break;
- case 5:clock_1();break;
- case 6:exit(0);break;
- default:exit(0);}
- } /*对特定的按键调用相应的函数*/
- void ping()
- {clrscr();
- window(1,1,80,1);
- textbackground(BLUE);
- clrscr();
- gotoxy(6,1);
- textcolor(WHITE);
- cprintf("Lunar-Calendar");/*设定日历主题条目。字体颜色及窗口大小*/
- window(2,1,4,1);
- textbackground(0);
- clrscr();
- window(1,2,80,22);
- textbackground(YELLOW);
- clrscr();/*设定主页面窗口大小、背景颜色*/
- window(1,23,80,25);
- textbackground(BLUE);
- clrscr();
- window(8,24,20,24);
- textbackground(15);/*设定按键栏的背景、字体大小、及窗口*/
- clrscr();
- sch_0();
- left();
- right();
- lun_();
- clock_();
- iexit();
- backk();
- calendar(2006);/*显示初始化年份*/
- }
- void nian(int year)
- {window(62,5,78,5);
- textbackground(RED);
- clrscr();
- textcolor(GREEN);
- cprintf("\n Calendar");
- window(64,7,75,11);
- textbackground(15);
- clrscr();
- textcolor(2);
- cprintf("\n Year");
- gotoxy(3,4);
- cprintf("%6d",year);
- window(62,13,78,20);
- textbackground(8);
- clrscr();
- textcolor(9);
- cprintf("\n=====welcom=====");
- gotoxy(1,4);
- cprintf(" calendar");
- gotoxy(1,6);
- cprintf(" system");
- return;/*设定桌面右侧的窗口、如欢迎进入日历系统。。。*/
- }
- main()
- {
- clrscr();
- sch_0();
- backk();
- left();
- right();
- lun_();
- clock();
- iexit();
- ping(); /*运行主函数*/
- calendar(2006);
- nian(2006);
- while(key!=28)
- {if(bioskey(1))key=bioskey(0);
- switch(key) /*设定相应按键函数*/
- {case LEFT:num--;jiance(num%7);key=0;break;
- case RIGHT:num++;jiance(num%7);key=0;break;
- case ENTER:jiance2(num%7);key=0;break;
- case ESC:exit(0);/*各按键功能函数*/
- default:key=0;break;}
- }
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|