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.

126 lines
2.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include<stdio.h>
//判断闰年
void f(year)
{
int year,day;
if(year%4==0&&year%100!=0||year%400==0)
return 1;
else
return 0;
}
void max_day(int year,int month)
{
int month_day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
if(f(year)==1)
mouth[1]=29;
return month_day[month-1];
}
//year总天数
void max_day(int year,int month,int day)
{
int sum=0,i;
for(i=1;i<month;i++)
{
sum+=max_day(i);
}
sum+=day;
return sum;
}
//星期几
void Weekday(int year,int month,int day)
{
int count,i,year_day,weekday;
for(i=1;i<year;i++) //总天数
{
if(f(i)==1)
year_day=366;
else
year_day=365;
count+=year_day;
}
count+=sum;
weekday=count%7;
return weekday;
}
//输出星期
void output_week(int year,int month,int day)
{
int weekday;
Weekday(year,month,day);
switch(weekday)
{
case 0:
printf("%d/%d/%d是星期天\n",year,month,day);
break;
case 1:
printf("%d/%d/%d是星期一\n",year,month,day);
break;
case 2:
printf("%d/%d/%d是星期二\n",year,month,day);
break;
case 3:
printf("%d/%d/%d是星期三\n",year,month,day);
break;
case 4:
printf("%d/%d/%d是星期四\n",year,month,day);
break;
case 5:
printf("%d/%d/%d是星期五\n",year,month,day);
break;
case 6:
printf("%d/%d/%d是星期六\n",year,month,day);
break;
}
}
//年历
void calendar(int year)
{
int i,j,k,l;
for(i=1;i<=12;i++)
{
printf("%d\n",i);
printf("日 一 二 三 四 五 六 \n")
for(j=0;j<weekday;j++) //开始位置
printf(" ") ;
l=1;
for(k=1;k<max_day(l);k++)
{
l++;
printf("%2d",k);
if((k+weekday)%7==0)
printf("\n");
return 0;
}
return 0;
}
}
void main()
{
//开始输出
printf("--------------------------选择服务--------------------------")
printf(" 1.日历显示")
printf(" 2.日期查询")
printf(" 3.距今多少天")
printf(" 4.退出")
printf("--------------------------选择服务--------------------------")
int n,year,month,day;
scanf("%d",&n);
switch (n)
{
case 1:
scanf("%d",year);
calendar(year);
}