寒窗轩,寒川的个人网络博客,记录互联网事,学习网络编程、分享工作经验、人生感悟,包括但不限于程序代码、数据库、Office办公、随笔等内容。

C语言写的一个万年历

#include<string.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,30,24);
 textbackground(GREEN);
 clrscr();
 textcolor(15);
 cprintf("\n Search");}


void sch_0()
{window(22,24,30,24);
 textbackground(GREEN);
 clrscr();
 textcolor(128);
 cprintf("\n Search ");}


 void backk()

 {window(33,24,42,24);
 textbackground(GREEN);
 clrscr();
 textcolor(15);
 cprintf("\n Month1-4");}


 void backk_0()
 {window(33,24,42,24);
 textbackground(GREEN);
 clrscr();
 textcolor(128);
 cprintf("\n Month1-4");}


void left()
{
 window(45,24,54,24);
 textbackground(GREEN);
 clrscr();
 textcolor(15);
 cprintf("\n Month5-8");}


 void left_0()
{
 window(45,24,54,24);
 textbackground(GREEN);
 clrscr();
 textcolor(128);
 cprintf("\n Month5-8");}


void right()
{window(57,24,67,24);
 textbackground(GREEN);
 clrscr();
 textcolor(15);
 cprintf("\n Month9-12");}


void right_0()
{window(57,24,67,24);
 textbackground(GREEN);
 clrscr();
 textcolor(128);
 cprintf("\n Month9-12");}

 

 

 

void iexit()
{window(70,24,77,24);
 textbackground(GREEN);
 clrscr();
 textcolor(15);
 cprintf("\n  Exit");}


void iexit_0()
{window(70,24,77,24);
 textbackground(GREEN);
 clrscr();
 textcolor(128);
 cprintf("\n  Exit");}

 

 


void jiance(int n)
{switch(n)
   {case 0:sch_0();left();right();iexit();backk();break;
    case 1:backk_0();left();right();iexit();sch();break;
    case 2:left_0();right();iexit();sch();backk();break;
    case 3:right_0();left();iexit();sch();backk();break;
    case 4:iexit_0();left();right();sch();backk();break;
    default:exit(0);
    }

}


void quzhi()
{window(8,24,20,24);
 textbackground(15);
 clrscr();
 textcolor(RED);
 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(GREEN);
     cprintf("            %s\n",month[i]);
     gotoxy(1,2);cprintf(" Mon Tue Wed Thu Fri Sat Sun");
     gotoxy(4*(fd[i]-1)+1,3);
     for(j=1;j<=mon[i];j++)
    {cprintf("%3d ",j);
     /*if((first+j-1)%7==0)putchar('\n');*/
     }
     /*first=(first+mon[i])%7;
     if(first==0)first=7;*/
     }
 for(i=2;i<4;i++)
    {window(2+(i-2)*w,13,29+w*(i-2),21);
     textbackground(5);
     clrscr();
     textcolor(GREEN);
     cprintf("            %s\n",month[i]);
     gotoxy(1,2);cprintf(" Mon Tue Wed Thu Fri Sat Sun");
     gotoxy(4*(fd[i]-1)+1,3);
for(j=1;j<=mon[i];j++)
    {cprintf("%3d ",j);
     /*if((first+j-1)%7==0)putchar('\n');*/
     }
     /*first=(first+mon[i])%7;
     if(first==0)first=7;*/
}
}

 


   void month5_8()
 {for(i=0;i<2;i++)
    {window(2+i*w,3,29+w*i,11);
     textbackground(5);
     clrscr();
     textcolor(GREEN);
     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);
     /*if((first+j-1)%7==0)putchar('\n');*/
     }
     /*first=(first+mon[i+4])%7;
     if(first==0)first=7;*/
}
 for(i=2;i<4;i++)
    {window(2+(i-2)*w,13,29+w*(i-2),21);
     textbackground(5);
     clrscr();
     textcolor(GREEN);
     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);
     /*if((first+j-1)%7==0)putchar('\n');*/
     }
     /*first=(first+mon[i+4])%7;
     if(first==0)first=7;*/
}
}


void month9_12()
{for(i=0;i<2;i++)
    {window(2+i*w,3,29+w*i,11);
     textbackground(5);
     clrscr();
     textcolor(GREEN);
     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);
     /*if((first+j-1)%7==0)putchar('\n');*/
     }
     /*first=(first+mon[i+8])%7;
     if(first==0)first=7;*/
}
 for(i=2;i<4;i++)
    {window(2+(i-2)*w,13,29+w*(i-2),21);
     textbackground(5);
     clrscr();
     textcolor(GREEN);
     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);
     /*if((first+j-1)%7==0)putchar('\n');*/
     }
     /*first=(first+mon[i+8])%7;
     if(first==0)first=7;*/
}
}

 


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();}

 


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:exit(0);break;
     default:exit(0);}
}

 

void ping()
{clrscr();
 window(1,1,80,1);
 textbackground(RED);
clrscr();
 gotoxy(6,1);
 textcolor(GREEN);
 cprintf("FILE   Record   Link    Help");
 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();
 iexit();
 backk();
 calendar(2006);
}

 

void copyright()
{clrscr();
 window(15,5,65,15);
 textbackground(RED);
 clrscr();
 textcolor(GREEN);
 cprintf("\n                  Calendar\n");
 gotoxy(1,4);
 cprintf("         My QQ: 331349451 Tel:08135507131\n");
 gotoxy(1,6);
 cprintf("               >September 19th,2006");
 gotoxy(1,8);
 cprintf("      Sichuan University of Scienc and Engineering  ");
 gotoxy(1,10);
 cprintf("             Jingxi Class 2,Grade 2004");
}


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(1);
 cprintf("\n    Year");
 gotoxy(3,4);
 cprintf("%6d",year);
 window(62,13,78,20);
 textbackground(8);
 clrscr();
 textcolor(9);
 cprintf("\n  Copyright(c)");
 gotoxy(1,4);
 cprintf(" Xieyan Wei");
 gotoxy(1,6);
 cprintf(" xieyanwei1985@163.com");
 return;
 }

 


main()
{clrscr();
 window(1,1,80,1);
 textbackground(RED);
 clrscr();
 gotoxy(6,1);
 textcolor(GREEN);
 cprintf("FILE   Record   Link    Help");
 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();
 copyright();
 sch_0();
 backk();
 left();
 right();
 iexit();
 getch();
 ping();
 calendar(2006);
 nian(2006);
 while(key!=28)
    {if(bioskey(1))key=bioskey(0);
     switch(key)
{case LEFT:num--;jiance(num%5);key=0;break;
 case RIGHT:num++;jiance(num%5);key=0;break;
 case ENTER:jiance2(num%5);key=0;break;
 case ESC:exit(0);
 default:key=0;break;}
     }

}
 

程序 2006-09-23 17:33:37 6 0 6858 编程C
文章写得不错?我是土豪我要在线打赏!
在线打赏

昵称:

验证码:验证码

评论:

文章分类
系统
程序
数据
Office
随笔
热门文章
请不要奇怪,为什么最近博客的文章是几年前的内容
Excel动态引用各表格指定单元格数据
开篇第一章
ubuntu24.04无法安装向日葵,提示依赖libgconf-2-4怎么办?
如何利用python修改文件的创建时间,修改时间,访问时间
发现一个好网站——春燕文档
ubuntu24.04安装网易云音乐
Ubuntu22.04中用thunar替换默认文件管理器,提示无法启动“TerminalEmulator“的首选应用程序
MySQL如何按每个分类查询10条数据,即MySQL如何每个分类查询10条数据
python读取旧的Excel文件的数据到新的Excel表中
文章推荐
免责声明
关于博主
开篇第一章
随机推荐
免责声明
最近比较忙。。。
猖獗的贼娃子
伤心的虚拟主机
pdf、word、txt、excel等文档转flash(swf)软件—虚拟打印机FlashPaper
Linux VS Windows 究竟哪个系统更好之思考
PHP上传超大表单数据丢失是什么情况?
html 5学习-audio标签插入音乐
2020岁末总结
人成熟的四个标准
友情连接
春燕网络
谢润的博客