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.

418 lines
12 KiB

6 years ago
#include<stdio.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <windows.h>
int year , month , day ;
int day_of_month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
//char wek[7]={'<27><><EFBFBD><EFBFBD>','<27><>һ','<27>ܶ<EFBFBD>','<27><><EFBFBD><EFBFBD>','<27><><EFBFBD><EFBFBD>','<27><><EFBFBD><EFBFBD>','<27><><EFBFBD><EFBFBD>'};
int current_year,current_month,current_day;
/************************************ͨ<>ùؼ<C3B9><D8BC><EFBFBD><EFBFBD><EFBFBD>**************************************************/
void cls_screen()
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
getchar();
getchar();
system("cls");
}
void get_current_time() //<2F><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1>
{
time_t timep;
struct tm *p;
time(&timep);
p = gmtime(&timep);
current_year=1900+p->tm_year;
current_month=1+p->tm_mon;
current_day=p->tm_mday;
}
int judgement (int y)
{
if (y % 400 == 0 || (y % 100 !=0 && y %4 ==0))
return 1 ;
else return 0 ;
}
int show_week (int year , int month , int day)
{
/*
<EFBFBD><EFBFBD>ʽ:w=(y+[y/4]+[c/4]-2c+[26(m+1)/10]+d-1)%7
*/
int w ,k; //<2F><>¼<EFBFBD>ܼ<EFBFBD>
int year_last=year %100,c=year/100 , m = month;
if (month==1 )
{
year_last-=1 ;
m=13 ;
}
else if (month==2)
{
year_last-=1;
m=14;
}
w = (year_last + year_last/4 + c/4 - 2*c +26*(m+1)/10+day-1); // abs <20><><EFBFBD><EFBFBD>ֵ
if (w<0)
{
k=(w%7+7)%7;
}
else k=w%7;
return k ;
}
/************************************<2A><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>**************************************************/
void print_year (int year)
{
int i , k ,x ,first_week;
printf ("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>ʽ<EFBFBD><CABD>2012):");
scanf ("%d",&year);
printf("=======================%d<><64>===========================\n",year);
printf("\n");
if (judgement(year))
{
day_of_month[1]=29;
}
else day_of_month[1]=28;
for (i=1 ; i <13 ; i++)
{
first_week = show_week(year,i,1);
printf("=====================%d<><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>========================\n",i);
printf ("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n");
for (x=1;x<=first_week;x++)
{
printf("\t");
if (x%7==0) printf ("\n");
}
for (k=1;k<=day_of_month[i-1];k++)
{
printf("%d\t",k);
if (x%7==0) printf ("\n");
x++;
}
printf("\n");
printf("\n");
printf("\n");
}
}
/************************************<2A>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD>**************************************************/
void print_year_month ()
{
int k ,x ,first_week;
printf ("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>ʽ<EFBFBD><CABD>2012 12):");
do
{
scanf ("%d %d",&year,&month);
if (month<1||month>12)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŷ~<7E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>·<EFBFBD>\n");
printf ("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>ʽ<EFBFBD><CABD>2012 12):");
}
}while(1>month||month>12);
printf("=====================%d<><64>%d<><64>======================\n",year,month);
if (judgement(year))
{
day_of_month[1]=29;
}
else day_of_month[1]=28;
first_week = show_week(year,month,1);
printf ("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n");
for (x=1;x<=first_week;x++)
{
printf("\t");
if (x%7==0) printf ("\n");
}
for (k=1;k<=day_of_month[month-1];k++)
{
printf("%d\t",k);
if (x%7==0) printf ("\n");
x++;
}
printf("\n");
}
/************************************<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>**************************************************/
int year_before_sumdays (int year,int month, int day)
{
int days=0 ,i,judgement1;
int temp_day=0 ,sum_days; //
//printf ("%d,%d\n",current_year,current_month);
judgement1=judgement(year);
/*===================<3D>ȵ<EFBFBD>ǰ<EFBFBD><C7B0>=====================*/
if (year < current_year )
{
for (i = year+1;i < current_year ;i++)
{
if (judgement(i))
{
days=days+356;
}
else days+=355;
}
for (i = month+1;i<=12;i++)
{
days=days+day_of_month[i-1];
}
days = days + day_of_month[month-1]-day; //ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD><EBB5B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
//printf("ȥ<><EFBFBD><EABBB9>%d\n",days);
for (i = 0;i < current_month-1;i++ )
{
if (judgement1)
{
day_of_month[1]=29;
}
temp_day = temp_day + day_of_month[i];
}
//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD>
temp_day = temp_day + current_day;
//printf("<22><><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>%d<><64>\n",temp_day);
sum_days=temp_day + days ;
}
/*===================<3D>ȵ<EFBFBD>ǰ<EFBFBD><C7B0>=====================*/
if (year > current_year )
{
for (i =current_year+1;i < current_year ;i++)
{
if (judgement(i))
{
days=days+356;
}
else days+=355;
}
for (i = current_month+1;i<=12;i++)
{
days=days+day_of_month[i-1];
}
days = days + day_of_month[month-1]-current_day; //ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>Ӿ<EFBFBD><D3BE><EFBFBD><EBB5B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
//printf("ȥ<><EFBFBD><EABBB9>%d\n",days);
for (i = 0;i <month-1;i++ )
{
if (judgement1)
{
day_of_month[1]=29;
}
temp_day = temp_day + day_of_month[i];
}
//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD>
temp_day = temp_day + day;
//printf("<22><><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>%d<><64>\n",temp_day);
sum_days=temp_day + days ;
}
/*===================<3D>ȵ<EFBFBD>ǰһ<C7B0><D2BB>=====================*/
if (year == current_year )
{
if(month <current_month)
{
for (i=month+1;i<current_month;i++)
{
if (judgement1)
{
day_of_month[1]=29;
}
days = days + day_of_month[i];
}
sum_days = days + current_day + day_of_month[month-1] - day ;
}
if (month>current_month)
{
for (i=current_month+1;i<month;i++)
{
if (judgement1)
{
day_of_month[1]=29;
}
days = days + day_of_month[i];
}
sum_days = days + day + day_of_month[month-1] - current_day ;
printf("%d\n",days);
}
if (month==current_month)
{
sum_days= abs(day-current_day);
}
}
return sum_days ;
}
void print(int year,int month,int day)
{
int week;
printf ("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>ʽ<EFBFBD><CABD>2012 12 12 ):");
do
{
scanf ("%d %d %d",&year,&month,&day);
if (judgement(year))
{
day_of_month[1]=29;
}
printf("\n");
if (day<=0 || day >day_of_month[month-1])
printf ("%d<><64>û<EFBFBD><C3BB>%d,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><>ʽ<EFBFBD><CABD>2012 12 12 ):",month,day);
}while(day<=0 || day >day_of_month[month-1]);
week=show_week (year,month ,day);
printf("\n");
switch(month)//<2F>жϲ<D0B6><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>н<EFBFBD><D0BD>յ<EFBFBD><D5B5>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
{
case 1:switch(day)
{
case 1:printf("Ԫ<EFBFBD><EFBFBD>") ;break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}break;
case 2:switch(day)
{
case 14:printf("<EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD>(Valentines Day)");break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}break;
case 3:switch(day)
{
case 8:printf("<EFBFBD><EFBFBD>Ů<EFBFBD>ڡ<EFBFBD><EFBFBD><EFBFBD>Women's Day)");break;
case 12:printf("ֲ<EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>Arbor Day)");break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}break;
case 4:switch(day)
{
case 1:printf("<EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD>(April Fools Day)");break;
case 5:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>Tomb-sweeping Day)");break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}break;
case 5:switch(day)
{
case 1:printf("<EFBFBD>Ͷ<EFBFBD><EFBFBD>ڣ<EFBFBD>Labor Day)");break;
case 4:printf("<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>Chinese Youth Day)");
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}break;
case 6:switch(day)
{
case 1:printf("<EFBFBD><EFBFBD>ͯ<EFBFBD><EFBFBD>(Children's Day)");break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}break;
case 8:switch(day)
{
case 1:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(the Army's Day)");break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}break;
case 9:switch(day)
{
case 10:printf("<EFBFBD><EFBFBD>ʦ<EFBFBD><EFBFBD>(Teacher's Day)");break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}break;
case 10:switch(day)
{
case 1:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(National Day)");break;
case 31:printf("<EFBFBD><EFBFBD>ʥ<EFBFBD><EFBFBD>(Helloween Day)");break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}break;
case 12:switch(day)
{
case 25 :printf("ʥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(Christmas Day)");break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}break;
}
printf("\n");
printf("%d<><64>%d<><64>%d<><64><EFBFBD><EFBFBD>:",year,month,day);
switch(week)//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>
{
case 0:printf("Sunday");break;
case 1:printf("Monday");break;
case 2:printf("Tuesday");break;
case 3:printf("Wednesday");;break;
case 4:printf("Thursday");break;
case 5:printf("Friday");break;
case 6:printf("Saturday");break;
}
printf("\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>\n",year_before_sumdays ( year, month, day));
printf("\n");
}
/********************************************************************************************/
int main (void)
{
int choice,year,month,day,flag=1;
char c , k;
for(;1;)//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>棬ÿ<E6A3AC>β<EFBFBD><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>
{
printf("===================================<3D>˵<EFBFBD>ѡ<EFBFBD><D1A1>===================================\n");
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>:\n");
printf("* * * * * * * * 1.<2E><><EFBFBD><EFBFBD>ijһ<C4B3><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> * * * * * * * *\n");
printf("* * * * * * * * 2.<2E><><EFBFBD><EFBFBD>ijһ<C4B3>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD> * * * * * * * *\n");
printf("* * * * * * * * 3.<2E><><EFBFBD><EFBFBD>ijһ<C4B3><D2BB> * * * * * * * *\n");
printf("* * * * * * * * 0.<2E>˳<EFBFBD> * * * * * * * *\n");
printf("==============================================================================\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>: ");
do
{
if (flag)
{
c=getchar();
printf("\n");
printf("ȷ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>%c<><63>? (y/Y )<29><><EFBFBD><EFBFBD>(n/N): ",c);
}
if (flag )
{
k=getchar();
// printf("\n");
}
if (k == 'y' || k == 'Y')
{
printf("\n");
if (c=='\n')
{
printf("\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>: ");
}
else if (!isdigit(c))
{
printf("\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>: ");
}
else if (isdigit(c))
{
choice = c-'0' ;
if (choice < 0 || choice > 3 )
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-3֮<33><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
}
else break ;
}
}
else if (k=='n' || k=='N')
{
printf("\n");
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>: ");
flag=1;
}
if ((k != 'y'&& k!='Y'&& k!= 'n'&& k!='N'))
{
printf("\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>y/n: ");
flag=0;
if (flag == 0)
{
k=getchar();
printf("\n");
//getchar();
}
}
}while(1);
if (choice==1)
{
print_year(year);
cls_screen();
}
else if (choice==2)
{
print_year_month ();
cls_screen();
}
else if (choice==3)
{
get_current_time();
print(year,month,day);
cls_screen();
}
else if (choice==0)
break;
else
{
printf ("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
}
}
}