C语言万年历另加运行图片.docxVIP

  • 8
  • 0
  • 约4.79千字
  • 约 10页
  • 2017-06-26 发布于湖北
  • 举报
C语言万年历另加运行图片

#includestdio.h#includewindows.h#includetime.h# define M 1911# define N 1# define Y 1int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};intm,n,z;//m代表年 n代表月void Search();//查找日历void get();//获取当前年月void menu();void left();void right();void up();void down();void today(intk,int y);//显示当月日历int Count (intyear,int month);//计算天数void textcolorBLUE(void);//设置字体为蓝色void textcolorGreen();void textcolorRED(void);//设置字体为红色void textcolorRED(void)//设置字体为红色{ HANDLE consolehwnd; consolehwnd = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleTextAttribute(consolehwnd,FOREGROUND_INTENSITY | FOREGROUND_RED);}void textcolorBLUE(void)//设置字体为红色{ HANDLE consolehwnd; consolehwnd = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleTextAttribute(consolehwnd,FOREGROUND_INTENSITY | FOREGROUND_INTENSITY);}void textcolorGREEN(void)//设置字体为绿色{ HANDLE consolehwnd; consolehwnd = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleTextAttribute(consolehwnd,FOREGROUND_INTENSITY | FOREGROUND_GREEN);}void get(){time_trawtime;//定义一个time_t型对象rawtime。struct tm * timeinfo;//定义一个时间结构指针struct tm 也是固定类型不能改变 time ( rawtime );timeinfo = localtime ( rawtime );m=1900+timeinfo-tm_year;//用x获取当日年n=1+timeinfo-tm_mon;z=timeinfo-tm_mday;printf(当前日期%d-%d-%d\t,m,n,z);}void left(){intk,s; s=--n; if(s=1) { k=Count(m,s); today(k,s); }}void right(){intk,s; s=++n; if(s=12) { k=Count(m,s); today(k,s); }}void up(){intk,s; s=++m; k=Count(s,n); today(k,n);}void down(){intk,s; s=--m; if(m=1911) { k=Count(s,n); today(k,n); }}void Search()//要判断输入为空这状态未作判断{intmm,nn,k;printf(请输入要查找的年分和月,用空格隔开\t);scanf(%d %d,mm,nn); k=Count(mm,nn); today(k,nn);}void menu(){intx,k;char ch;printf(W/w上一年,S/s下一年,A/a上一个月,D/d下一个月,Q/q查找日历红色代表当前日期\n);get(); if((m%4==0m%100!=0)||(m%100==0m%400==0)){printf(今年是闰年\t);printf(共有366天\n);}else{printf(今年不是闰年\t);printf(共有365天\n);} k=Count(m,n);//计算天数 today(k,n); while(1){ if(kbhit()) {ch=getch(); switch(ch){ case

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档