万年历C语言数据结构设计,万年历设计报告

本文介绍了一个C++程序,用于判断给定年份是否为闰年,并提供月日查询功能,以及打印指定年份的完整日历。通过IsLeapYear函数确定闰年规则,Month_day函数计算月份天数,DaySearch用于查找特定日期对应的星期,PrintAllYear则展示全年日历。
摘要由CSDN通过智能技术生成

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

#include

#include

char* month_str[]={"January","February","March","April","May","June","July","August","September","October","November","December"};

char* week[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

int IsLeapYear(int year) /*find out the year is leap year or not*/

{

if((year%4==0&&year%100!=0)||(year%400==0))

return 1;

else

return 0;

}

int month_day(int year,int month)

{

int mon_day[]={31,28,31,30,31,30,31,31,30,31,30,31};

if(IsLeapYear(year)&&month==2)

return 29;

else

return(mon_day[month-1]);

}

int DaySearch(int year,int month,int day) /*search what day this day is*/

{

int c=0;

float s;

int m;

for(m=1;m

c=c+month_day(year,m);

c=c+day;

s=year-1+(float)(year-1)/4+(float)(year-1)/100+(float)(year-1)/400-40+c;

return ((int)s%7);

}

int PrintAllYear(int year)/*print the all year*/

{

int temp;

int i,j;

printf("\n\n%d Calander\n",year);

for(i=1;i<=12;i++)

{

printf("\n\n%s(%d)\n",month_str[i-1],i);

printf("0 1 2 3 4 5 6 \n");

printf("S M T W T F S \n\n");

temp=DaySearch(year,i,1);

for(j=1;j<=month_day(year,i)+temp;j++)

{

if(j-temp<=0)

printf(" ");

else if(j-temp<10)

printf("%d ",j-temp);

else

printf("%d ",j-temp);

if(j%7==0)

printf("\n");

}

}

return 0;

}

int main()

{

int option,da;

char ch;

int year,month,day;

printf("Copyright @ 2005 TianQian All rights reserved!:):):)");

printf("\n\nWelcome to use the WanNianLi system!\n");

while(1)

{

printf("\nPlease select the service you need:\n");

printf("\n1 Search what day the day is");

printf("\n2 Search whether the year is leap year or not");

printf("\n3 Print the calander of the whole year");

printf("\n4 Exit\n");

scanf("%d",&option);

switch(option)

{

case 1:

while(1)

{

printf("\nPlease input the year,month and day(XXXX,XX,XX):");

scanf("%d,%d,%d,%c",&year,&month,&day);

da=DaySearch(year,month,day);

printf("\n%d-%d-%d is %s,do you want to continue?(Y/N)",year,month,day,week[da]);

fflush(stdin);

scanf("%c",&ch);

if(ch=='N'||ch=='n')

break;

}

break;

case 2:

while(1)

{

printf("\nPlease input the year which needs searched?(XXXX)");

scanf("%d",&year);

if(IsLeapYear(year))

printf("\n%d is Leap year,do you want to continue?(Y/N)",year);

else

printf("\n%d is not Leap year,do you want to continue(Y/N)?",year);

fflush(stdin);

scanf("%c",&ch);

if(ch=='N'||ch=='n')

break;

}

break;

case 3:

while(1)

{

printf("\nPlease input the year which needs printed(XXXX)");

scanf("%d",&year);

PrintAllYear(year);

printf("\nDo you want to continue to print(Y/N)?");

fflush(stdin);

scanf("%c",&ch);

if(ch=='N'||ch=='n')

break;

}

break;

case 4:

fflush(stdin);

printf("Are you sure?(Y/N)");

scanf("%c",&ch);

if(ch=='Y'||ch=='y')

exit(0);

break;

default:

printf("\nError:Sorry,there is no this service now!\n");

break;

}

}

return 0;

}

数据很详细 CREATE TABLE `zb_calendar` ( `GregorianDateTime` varchar(255) DEFAULT NULL COMMENT '公历日期时间', `LunarDateTime` varchar(255) DEFAULT NULL COMMENT '农历日期时间', `LunarShow` varchar(255) DEFAULT NULL, `IsJieJia` varchar(255) DEFAULT NULL, `LJie` varchar(255) DEFAULT NULL COMMENT '农历节日', `GJie` varchar(255) DEFAULT NULL COMMENT '公历节日', `Yi` varchar(255) DEFAULT NULL COMMENT '宜', `Ji` varchar(255) DEFAULT NULL COMMENT '忌', `ShenWei` varchar(255) DEFAULT NULL COMMENT '神位', `Taishen` varchar(255) DEFAULT NULL COMMENT '胎神', `Chong` varchar(255) DEFAULT NULL COMMENT '冲煞', `SuiSha` varchar(255) DEFAULT NULL COMMENT '岁煞', `WuxingJiazi` varchar(255) DEFAULT NULL COMMENT '五行甲子', `WuxingNaYear` varchar(255) DEFAULT NULL COMMENT '纳音五行年', `WuxingNaMonth` varchar(255) DEFAULT NULL COMMENT '纳音五行月', `WuxingNaDay` varchar(255) DEFAULT NULL COMMENT '纳音五行日', `MoonName` varchar(255) DEFAULT NULL COMMENT '农历月名称', `XingEast` varchar(255) DEFAULT NULL COMMENT '星宿吉凶(东方星座)', `XingWest` varchar(255) DEFAULT NULL COMMENT '四方(星座)', `PengZu` varchar(255) DEFAULT NULL COMMENT '彭祖百忌', `JianShen` varchar(255) DEFAULT NULL COMMENT '黄历12值神建', `TianGanDiZhiYear` varchar(255) DEFAULT NULL COMMENT '天干地支年', `TianGanDiZhiMonth` varchar(255) DEFAULT NULL COMMENT '天干地支月', `TianGanDiZhiDay` varchar(255) DEFAULT NULL COMMENT '天干地支日', `LMonthName` varchar(255) DEFAULT NULL COMMENT '农历月名称', `LYear` varchar(255) DEFAULT NULL COMMENT '生肖', `LMonth` varchar(255) DEFAULT NULL COMMENT '农历月', `LDay` varchar(255) DEFAULT NULL COMMENT '农历日', `SolarTermName` varchar(255) DEFAULT NULL COMMENT '农历节气的名称' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='万年历';
#include int main (void) { int year,month,j,i,day1,day2,one1,one2,w; printf("enter a year:"); scanf("%d",&year); printf("\n\n"); printf("---------------------%d---------------------\n\n",year); one1=((year-1)*365+(year-1)/4-(year-1)/100+(year-1)/400+1)%7; for(month=1;month<=12;month+=2) { printf(" ",month,year); printf(" \n",month+1,year); printf("-------------------- --------------------\n"); printf("日 一 二 三 四 五 六 日 一 二 三 四 五 六\n"); switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: day1=31;break; case 4: case 6: case 9: case 11:day1=30;break; default:if(!(year%4)&&(year0)||!(year%400)) day1=29; else day1=28; } for(j=1;j<=one1;j++) { if(one1==7) break; else printf(" "); } for(i=1;i<=7-one1;i++) printf("%2d ",i); printf(" "); switch(month+1) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: day2=31;break; case 4: case 6: case 9: case 11:day2=30;break; default:if(!(year%4)&&(year0)||!(year%400)) day2=29; else day2=28; } one2=(one1+day1)%7; for(j=1;j<=one2;j++) { if(one2==7) break; if(j!=7) printf(" "); } for(i=1;i<=7-one2;i++) printf("%2d ",i); printf("\n"); for(i=8-one1;i<=14-one1;i++) printf("%2d ",i); printf(" "); for(i=8-one2;i<=14-one2;i++) printf("%2d ",i); printf("\n"); for(i=15-one1;i<=21-one1;i++) printf("%2d ",i); printf(" "); for(i=15-one2;i<=21-one2;i++) printf("%2d ",i); printf("\n"); for(i=22-one1;i<=28-one1;i++) printf("%2d ",i); printf(" "); for(i=22-one2;i<=28-one2;i++) printf("%2d ",i); printf("\n"); for(i=29-one1;i<=35-one1&&i<=day1;i++) printf("%2d ",i); printf(" "); for(w=1;w<=35-day1-one1;w++) printf(" "); for(i=29-one2;i<=35-one2&&i<=day2;i++) printf("%2d ",i); printf("\n"); for(i=36-one1;i<=day1;i++) printf("%2d ",i); for(w=1;w<=35-day1-one1;w++) printf(" "); if(day1==31&&(one1==4||one1==3||one1==2||one1==1||one1==7)) printf(" "); if(day1==30&&(one1==4||one1==3||one1==2||one1==1||one1==7)) printf(" "); for(i=36-one2;i<=day2;i++) printf("%2d ",i); printf("\n-------------------- --------------------\n\n"); printf("\n"); one1=(one2+day2)%7; } printf("---------------------%d---------------------\n",year); getchar(); printf("按任意键退出"); getchar(); return 0; }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值