(精!!!!c语言)多功能万年历
- 格式:docx
- 大小:14.33 KB
- 文档页数:4
#include
#include
#include
void print_star()
{
printf("************************************************************************* ******\n");
}
void main()
{ system("COLOR b1");
void tools_1();
void tools_2();
char flag;
printf("\t\t\t\t*************************************************\n");
printf("\t\t\t\t**************欢迎使用万年历查询系统*************\n");
printf("\t\t\t\t*************************************************\n\n\n");
printf("Hi,user!下面是系统的一些功能:\n"); /*菜单*/
printf("1.查询任意一年的日历\n");
printf("2.查询任意一天是星期几\n");
print_star();
print_star();
printf("\n\nNow,your choice:");
scanf("%c",&flag);/*用户选择*/
switch(flag)
{case'1':tools_1();
case'2':tools_2();
}
}
void tools_1()/*功能一*/
{int year_month_day(int a),a,f;
void year(int ,int);
printf("请输入需要查看的年份(公元元年--.....):");
while(scanf("%d",&a)!='EOF')
{printf("********【%d】********\n",a);
f=year_month_day(a)%7+1;//计算所要查询年份的一月一号为星期几//
if(a==1)//初始化公元元年(公元元年为0001年,星期一)
f=1;
year(f,a);
printf("\n现在可继续查询.......若要退出请按
}
}
void year(int f,int a)//打印日历//
{
int s[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
char months[13][20]={" ","January","February","March","April","May","June","July","August","September","Octomber"," November","December"};
char weeks[7][10]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
int i,d,j,t=f;
for(i=1;i<=12;i++)
{ printf("\n");
print_star();
printf("%40s\n",months[i]);
print_star();
for(d=0;d<7;d++)
printf("%-12s",weeks[d]);
printf("\n");
for(d=0;d printf(" "); t=d; for(j=1;j<=s[i];j++) {printf("%-12d",j); t++; if(t%7==0) printf("\n"); } if(((a%400==0)||(a%100!=0&&a%4==0))&&j==29)//如果是闰年,2月多打一天// {printf("%-12d",j); t++;} if(t%7==0) printf("\n"); t=t%7; } system("color a"); //闪光函数 Sleep(100); system("color b"); Sleep(100); system("color c"); Sleep(100); system("color d"); Sleep(100); system("color e"); Sleep(100); system("color f"); Sleep(100); system("color 0"); Sleep(100); } int year_month_day(int a)//计算从公元元年到所求年份之间的天数 { int year_month_day_(int ); int d=0,f;