C语言写的一个万年历

2006-9-23 寒川 计算机

#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;}
     }

}
 

标签: 编程 C

评论(0) 浏览(7139)

二级是狗屎

2006-9-23 寒川 点滴心情

我不是因为没考过2级才这么说。虽然我很想过2级,但是说实在的,就我们这些非计算机专业的学生,过了二级也还是计算机白痴,这可不是吹牛的!什么C语言,什么VB,什么Access,学得要懂不懂的。一点适用价值都没有。但是出去工作企业要看你的计算机等级证书。真不知道那些老板们是怎么想的。其实他们一点都不知道,即使是过了计算机2级的,也没几个能搞出一个多么好的程序来。
  我报了两次计算机了,即使这次能过,我照样说2级是狗屎。这不是吹的!……
  还不如学点有用的计算机基础。比如:Powerpint、 Word、Fontpage、Excel、Auto CAD、Photoshop CS。呵呵~~我觉得这些比起无聊的程序来安逸得多了。

标签: 计算机 学习

评论(0) 浏览(6590)

上网中

2006-9-21 寒川 点滴心情

    又快要2级考试了,不知道这次是否能过?真他妈的难. 好不安逸哦。想认真学习C现在是不可能的了。最近特别喜欢C,但是以前学了都忘了好多。怎么考试?!

 

标签: 心情 学习

评论(0) 浏览(7091)

搬校区了

2006-7-14 寒川 点滴心情

搬校区了。真是不安逸!

标签: 心情

评论(2) 浏览(7445)

Powered by emlog 蜀ICP备12030225号

川公网安备 51042102000001号

sitemap