You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

358 lines
5.8 KiB

6 years ago
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<time.h>
// ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int month_day(int year,int month)
{
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return 31;break;
case 4:
case 6:
case 9:
case 11:
return 30;break;
case 2:
if((year%4==0)&&(year%100!=0)||(year%400==0))
{
return 29;
break;
}
else
{
return 28;
break;
}
}
}
// <20><><EFBFBD><EFBFBD>
void year_calendar(int year)
{
int month,days,weekday,sum_day;
int i,j;
year;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>");
scanf("%d",&year);
for(i=1;i<year;i++)
{
if((year%4==0)&&(year%100!=0)||(year%400==0))
sum_day+=366;
else
sum_day+=365;
}
for(month=1;month<=12;month++)
{
printf("\n--------%d/%d--------\n",year,month);
printf("SUN\tMON\tTUE\tWED\tTHU\tFRI\tSAT\t\n");
i=1;
j=1;
weekday=sum_day%7;
while(i<=weekday) //<2F><>ʼλ<CABC><CEBB>ǰ<EFBFBD><C7B0><EFBFBD>ǿո<C7BF>
{
printf("\t");
i++;
}
while(j<=month_day(year,month))
{
weekday=sum_day%7;
if (weekday==6)
printf("%d\n",j);
else
printf("%d\t",j);
if(j==month_day(year,month))
printf("\n");
j++;
sum_day++;
}
}
}
// <20><><EFBFBD><EFBFBD>
void month_calendar(int year,int month)
{
int sum_day=0,weekday,i,j,k;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F>£<EFBFBD>");
scanf("%d/%d",&year,&month);
for(i=1;i<year;i++)
{
if((year%4==0)&&(year%100!=0)||(year%400==0))
sum_day+=366;
else
sum_day+=365;
}
for(k=1;k<month;k++)
{
sum_day+=month_day(year,month);
}
printf("\n\t--------%d/%d--------\n",year,month);
printf("\tSUN\tMON\tTUE\tWED\tTHU\tFRI\tSAT\t\n");
i=1;
j=1;
weekday=sum_day%7;
while(i<=weekday) //<2F><>ʼλ<CABC><CEBB>ǰ<EFBFBD><C7B0><EFBFBD>ǿո<C7BF>
{
printf("\t");
i++;
}
while(j<=month_day(year,month))
{
weekday=sum_day%7;
if (weekday==6)
printf("%d\n",j);
else
printf("%d\t",j);
if(j==month_day(year,month))
printf("\n");
j++;
sum_day++;
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void Time(int year,int month,int day)
{
time_t t;//<2F><>t<EFBFBD><74><EFBFBD><EFBFBD>Ϊʱ<CEAA><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
struct tm *p;//struct tm<74><6D>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><E5A3AC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><E1B9B9>ָ<EFBFBD><D6B8>
time(&t);
p=localtime(&t);//<2F><><EFBFBD>õ<EFBFBD>ǰʱ<C7B0><CAB1>
int now_year,now_month,now_day;
now_year=1900+p->tm_year;
now_month=1+p->tm_mon;
now_day=p->tm_mday;
printf("<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD>%d/%d/%d\n",now_year,now_month,now_day);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int i,k,sum_day;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><>/<2F>գ<EFBFBD>");
scanf("%d/%d/%d",&year,&month,&day);
for(i=1;i<year;i++)
{
if((year%4==0)&&(year%100!=0)||(year%400==0))
sum_day+=366;
else
sum_day+=365;
}
for(k=1;k<month;k++)
{
sum_day+=month_day(year,month);
}
sum_day+=day;
//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int j,sum_nowday;
for(j=1;j<now_year;j++)
{
if((now_year%4==0)&&(now_year%100!=0)||(now_year%400==0))
sum_nowday+=366;
else
sum_nowday+=365;
}
for(k=1;k<now_month;k++)
{
sum_nowday+=month_day(now_year,now_month);
}
sum_nowday+=now_day;
//<2F><><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD>ֵ
if(sum_day>sum_nowday)
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵱ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>",sum_day-sum_nowday);
else
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵱ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>",sum_nowday-sum_day);
}
//<2F><><EFBFBD>ڲ<EFBFBD>ѯ
void rq(int year,int month,int day)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><>/<2F>գ<EFBFBD>");
int sum_day,i,k,weekday;
scanf("%d/%d/%d",&year,&month,&day);
for(i=1;i<year;i++)
{
if((year%4==0)&&(year%100!=0)||(year%400==0))
sum_day+=366;
else
sum_day+=365;
}
for(k=1;k<month;k++)
{
sum_day+=month_day(year,month);
}
sum_day+=day;
weekday=sum_day%7;
printf("\n");
switch(weekday)
{
case 0:
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
break;
}
case 1:
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ");
break;
}
case 2:
{
printf("<EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>");
break;
}
case 3:
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
break;
}
case 4:
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
break;
}
case 5:
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
break;
}
case 6:
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
break;
}
}
printf("\n\n");
if(month==1)
{
if(day==1)
printf("Ԫ<EFBFBD><EFBFBD>");
}
else if(month==2)
{
if(day==14)
printf("<EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD>");
}
else if(month==3)
{
switch(day)
{
case 8:printf("<EFBFBD><EFBFBD>Ů<EFBFBD><EFBFBD>");break;
case 12:printf("ֲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");break;
}
}
else if(month==4)
{
if(day==1)
printf("<EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD>");
}
else if(month==5)
{
switch(day)
{
case 1:printf("<EFBFBD>Ͷ<EFBFBD><EFBFBD><EFBFBD>");break;
case 4:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");break;
}
}
else if(month==6)
{
if(day==1)
printf("<EFBFBD><EFBFBD>ͯ<EFBFBD><EFBFBD>");
}
else if(month==7)
{
if(day==1)
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
else if(month==8)
{
if(day==1)
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
else if(month==9)
{
if(day==10)
printf("<EFBFBD><EFBFBD>ʦ<EFBFBD><EFBFBD>");
}
else if(month==10)
{
if(day==1)
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
else if(month==11)
{
;
}
else
{
if(day==25)
printf("ʥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
}
int main(void)
{
printf("\n-------------------ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-------------------\n\n");
printf(" 1.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ\n");
printf(" 2.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ\n");
printf(" 3.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf(" 4.<2E><><EFBFBD>ڲ<EFBFBD>ѯ\n");
printf(" 5.<2E>˳<EFBFBD>\n");
printf("\n-------------------ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-------------------\n") ;
int n,year,month,day;
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&n);
switch(n)
{
case 1:
{
year_calendar(year);
break;
}
case 2:
{
month_calendar(year,month);
break;
}
case 3:
{
Time(year,month,day);
break;
}
case 4:
{
rq(year,month,day);
break;
}
case 5:
{
return 0;
}
}
}