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.

299 lines
6.6 KiB

6 years ago
#include <stdio.h>
#include<string.h>
#include<time.h>
int rulueri(int,int,int);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD><D5A3><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void print(int,int);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int weekday(int ,int ,int );//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ڼ<EFBFBD>
int all_day(int ,int );//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
void gongneng(int );//ִ<><D6B4><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
void jieri(int,int);//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void xianshi1();//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
void xianshi2();//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
void xianshi3();//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
int panduan();//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int xuanxiang();//<2F><>¼ѡ<C2BC><D1A1>
int timeyear;
int timemonth;
int timeday;
int rulueri(int year,int month,int day)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
int b=0;
double dd;
if(month<=2)
{
month+=12;//<2F><><EFBFBD>·ݽ<C2B7><DDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
year-=1;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
b=year/100;
b=2-b+year/400;
dd=day+0.5000115740;//<2F><><EFBFBD><EFBFBD>12:00<30><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յĿ<D5B5>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ӣ<EFBFBD>
return (365.25*(year+4716)+0.01)+(30.60001*(month+1))+dd+b-1524.5;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յĹ<D5B5>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
}
void print(int week, int day)//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
int i=0,j=1;//i:ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> j:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ5,6<>ǵ<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>Χ
int date=1;//<2F>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int flag=week;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>пո<D0BF>
printf("<EFBFBD><EFBFBD> һ <20><> <20><> <20><> <20><> <20><>\n");
if(week>=5)
j+=1;
for (i=0; i<(day+week)/7+j; i++)
{
int j=0;
int k=0;
for (j=0; j<week; j++)
{
if (flag!=0)
{
printf(" ");
}
flag--;
}
for (k=0;k<7-week;k++)
{
printf("%2d ",date);
date++;
if (date > day)
{ printf("\n");
break;
}
}
if (date > day)
{ printf("\n");
break;
} week = 0;
printf("\n");
}
}
int weekday(int year,int month,int day)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ڼ<EFBFBD>
{
int m,d,y,c,w;//y:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>m:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>d:ij<><C4B3><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>c:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-1<><31>w:<3A><><EFBFBD><EFBFBD>
m = month;
d = day;
if(month <= 2) /*<2A><>С<EFBFBD><D0A1>2<EFBFBD><32><EFBFBD>·ݽ<C2B7><DDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
{
year--;
m = month + 12;
}
y = year % 100;
c = year / 100;
w = (y + y / 4 + c / 4 - 2 * c + (13 * (m + 1) / 5) + d - 1) % 7;//<2F><><EFBFBD>չ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>
if(w < 0) /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
w += 7;
return w;
}
int all_day(int y ,int m)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>
{
int flag = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int day = 30;
if (((y % 4 == 0) && (y % 100 == 0)) || (y % 400 == 0))
{
flag = 1;
}
if ((m == 1) || (m == 3) || (m == 5) || (m == 7)
|| (m == 8) || (m == 10) || (m == 12))
{
day = 31;
}
else if ((m == 2) && (flag == 1))
{
day = 29;
}
else if ((m == 2) && (flag == 0))
{
day = 28;
}
else
day = 30;
return day;
}
void gongneng(int num)//<2F>ѡ<E1B9A9>񣬲<EFBFBD><F1A3ACB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
{
int year = 0;
int month = 0;
int week = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·ݵ<C2B7>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD>
int dday = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD>¹<EFBFBD><C2B9>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
int day;
switch(num)
{
case 2:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>\n");
scanf("%d%d", &year, &month);
week = weekday(year, month,1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>µ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>
dday = all_day(year, month);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD>¹<EFBFBD><C2B9>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
printf("%d<><64>************************\n",month);
print(week, dday);
break;
case 1:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>\n");
scanf("%d",&year);
for(month=1;month<=12;month++)
{ printf("%d<><64>********************\n",month);
week = weekday(year, month,1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>
dday = all_day(year, month);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD>¹<EFBFBD><C2B9>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
print(week, dday);
}
break;
case 3:
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><EFBFBD><EFBFBD>:\n");
scanf("%d%d%d",&year,&month,&day);
if(rulueri(year,month,day)<=rulueri(timeyears(),timemonths(),timedays()))//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ڽ<EFBFBD><DABD><EFBFBD>֮ǰ
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>\n",rulueri(timeyears(),timemonths(),timedays())-rulueri(year,month,day));
else
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>\n",rulueri(year,month,day)-rulueri(timeyears(),timemonths(),timedays()));
if(weekday(year,month,day)!=0)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0Ϊ7
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d\n",weekday(year,month,day));
else
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>7\n");
jieri(month,day);
break;
}
}
void jieri(int month,int day)//<2F>жϲ<D0B6><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
if(month==1&&day==1)
printf("%d<><64>%d<><64><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>\n",month,day);
else if(month==3&&day==8)
printf("%d<><64>%d<><64><EFBFBD>Ǹ<EFBFBD>Ů<EFBFBD><C5AE>\n",month,day);
else if(month==3&&day==12)
printf("%d<><64>%d<><64><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD>\n",month,day);
else if(month==5&&day==1)
printf("%d<><64>%d<><64><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>\n",month,day);
else if(month==5&&day==4)
printf("%d<><64>%d<><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n",month,day);
else if(month==6&&day==1)
printf("%d<><64>%d<><64><EFBFBD>Ƕ<EFBFBD>ͯ<EFBFBD><CDAF>\n",month,day);
else if(month==7&&day==1)
printf("%d<><64>%d<><64><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD>\n",month,day);
else if(month==8&&day==1)
printf("%d<><64>%d<><64><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD>\n",month,day);
else if(month==9&&day==10)
printf("%d<><64>%d<><64><EFBFBD>ǽ<EFBFBD>ʦ<EFBFBD><CAA6>\n",month,day);
else if(month==10&&day==1)
printf("%d<><64>%d<><64><EFBFBD>ǹ<EFBFBD><C7B9><EFBFBD><EFBFBD><EFBFBD>\n",month,day);
else
printf("<EFBFBD><EFBFBD><EFBFBD>ղ<EFBFBD><EFBFBD>ǹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD>\n");
}
void xianshi1()//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
{
printf("\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾϵͳ\t\t\n");
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>\n");
printf("1.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n2.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>\n3.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><ECA3AC><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
void xianshi2()//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
{
printf("<EFBFBD>޷<EFBFBD>ʶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
}
void xianshi3()//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
{
printf("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Y<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>N<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
}
int xuanxiang()//<2F><>¼ѡ<C2BC><D1A1>
{
int num;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ѡ<EFBFBD><D1A1>
scanf("%d",&num);
return num;
}
int panduan()//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
char suz[100],y[]="y",n[]="n",Y[]="Y",N[]="N";
scanf("%s",suz);
if(strcmp(suz,y)==0||strcmp(suz,Y)==0)
return 2;
else if(strcmp(suz,n)==0||strcmp(suz,N)==0)
return 1;
else
return 0;
}
int timeyears()
{
int year;
struct tm *local;
time_t t;
t=time(NULL);
local=localtime(&t);
year=local->tm_year+1900;
return year;
}
int timemonths()
{
int month;
struct tm *local;
time_t t;
t=time(NULL);
local=localtime(&t);
month=local->tm_mon+1;
return month;
}
int timedays()
{
int day;
struct tm *local;
time_t t;
t=time(NULL);
local=localtime(&t);
day=local->tm_mday;
return day;
}
int main()
{
int x=-1;//<2F><><EFBFBD><EFBFBD><EFBFBD>жϺ<D0B6><CFBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
while(1)
{ xianshi1();
gongneng(xuanxiang());
fflush(stdin);
xianshi3();
while(1)
{
x=panduan();
fflush(stdin);
if(x==0)
{ fflush(stdin);
xianshi2();
xianshi3();
continue;
}
else if(x!=0)
break;
}
if(x==1)
break;
else if(x==2)
continue;
}
return 0;
}