c語言萬年曆項目?包括閏年、生肖、星座的判斷#include<stdio.h>,現在小編就來說說關于c語言萬年曆項目?下面内容希望能幫助到你,我們來一起看看吧!
包括閏年、生肖、星座的判斷
#include<stdio.h>
int main(){
int mon,year,week,day,a,b,c,e,f,g,count; // mon 月份, year 年份 , week 星期幾,a 用于判斷日期的數量是否超過當月的最大日期 ,e 算每個月第一天是星期幾,g 輸出月份的标題
static int d[12][78]; // 每月每日
int m[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; // m 每月最後一天的日期
char wst[]=" Sun Mon Tue Wed Thu Fri Sat ";
printf("請輸入要查詢的年份:");
scanf("%d",&year);
printf("\n");
count = (year % 12) - 3;
if (count < 0)
{
count = count 12;
}
switch (count)
{
case 0:
printf("豬年"); break;
case 1:
printf("鼠年"); break;
case 2:
printf("牛年"); break;
case 3:
printf("虎年"); break;
case 4:
printf("兔年"); break;
case 5:
printf("龍年"); break;
case 6:
printf("蛇年"); break;
case 7:
printf("馬年"); break;
case 8:
printf("羊年"); break;
case 9:
printf("猴年"); break;
case 10:
printf("雞年"); break;
case 11:
printf("狗年"); break;
}
if(year%4==0&&year0!=0||year@0==0)
m[2]=29;
e=(year (year-1)/4-(year-1)/100 (year-1)/400)%7;
for(mon=1;mon<=12;mon ){
a=1;
for(b=1;b<=6;b ){
for(week=0;week<=6;week ){
while(week<e)week=week 1;
d[mon][b*10 week]=a;
a=a 1;
e=week 1;
if(e==7)e=0;
if(a>m[mon])break;
}
if(a>m[mon])break;
}
}
for(week=1;week<=16*2-3;week )
printf(" ");
printf("******%d年******\n",year);
for (c=1;c<=6;c ){
g=2*(c-1) 1;
printf("\n ");
for(f=1;f<=2;f ){
for(week=1;week<=15;week )
printf(" ");
printf("-月",g f-1);
for(week=1;week<=14;week )
printf(" ");
}
printf("\n ");
for(f=1;f<=2;f )
printf("%s",wst);
for(b=1;b<=6;b ){
printf("\n ");
for(mon=g;mon<=g 1;mon ){
printf(" ");
for(week=0;week<=6;week )
if(d[mon][b*10 week]==0)
printf(" ");
else
printf("M",d[mon][b*10 week]);
}
}
}
printf("\n請輸入要查詢星座的月份和日期(空格分開):");
scanf("%d %d",&mon,&day);
if((mon==12&&day>=21)||(mon==1&&day<=19))
printf("摩羯座");
else if((mon==1&&day>=19)||(mon==2&&day<=18))
printf("水瓶座");
else if((mon==2&&day>=18)||(mon==3&&day<=20))
printf("雙魚座");
else if((mon==3&&day>=21)||(mon==4&&day<=19))
printf("白羊座");
else if((mon==4&&day>=20)||(mon==5&&day<=20))
printf("金牛座");
else if((mon==5&&day>=21)||(mon==6&&day<=21))
printf("雙子座");
else if((mon==6&&day>=22)||(mon==7&&day<=22))
printf("巨蟹座");
else if((mon==7&&day>=23)||(mon==8&&day<=22))
printf("獅子座");
else if((mon==8&&day>=23)||(mon==9&&day<=22))
printf("處女座");
else if((mon==9&&day>=23)||(mon==10&&day<=23))
printf("天秤座");
else if((mon==10&&day>=24)||(mon==11&&day<=22))
printf("天蠍座");
else
printf("射手座");
return 0;
}
,更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!