万年历软件各个接口功能的实现

本文介绍了万年历软件的主要功能,包括日历显示、查询、修改、日期备忘录及信息帮助。作者强调虽然已实现各接口功能,但为了提升用户体验仍有改进空间。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

万年历软件可以实现日历显示,日历查询,日历修改,日期备忘录,信息帮助这些功能:


#include<stdio.h>
#include"CalendarTable.h"
#include<stdlib.h>
int main()
{
CalendarTable();
system("pause");
return 0;
}


/****************************************************************************************/

#pragma once
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include"time.h"
#include<assert.h>
#include<stdlib.h>
#include<string.h>
void CalendarTable();
void CalculateDay();
void ShowEveryMonth();
int JudgeLeapYear();
int JudgeMonth();
void AlterCalendarTable();

/**************************************************************************/
void ShowEveryMonth(int year)
{
int month=1;
while (month <= 12)
{
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))//是闰年
{
//printf("是闰年\n");
printf("************************\n");
//printf("本月日历\n");
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)//1 3 5 7 8 10 12月的日历
{
printf("1  2  3  4  5  6 7\n");
printf("8  9  10  11  12  13  14\n");
printf("15  16  17  18  19  20  21\n");
printf("22  23  24  25  26  27  28\n");
printf("29  30  31\n");
}
else if (month == 4 || month == 6 || month == 9 || month == 11)//4 6 9 11月的日历
{
//printf("其他月份\n");
printf("1  2  3  4  5  6 7\n");
printf("8  9  10  11  12  13  14\n");
printf("15  16  17  18  19  20  21\n");
printf("22  23  24  25  26  27  28\n");
printf("29  30\n");
}
else//2月的日历
{
printf("1  2  3  4  5  6 7\n");
printf("8  9  10  11  12  13  14\n");
printf("15  16  17  18  19  20  21\n");
printf("22  23  24  25  26  27  28\n");
printf("29\n");
}
}
else
{
//printf("不是闰年\n");
printf("************************\n");
//printf("本月日历\n");
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)//1 3 5 7 8 10 12月的日历
{
printf("1  2  3  4  5  6 7\n");
printf("8  9  10  11  12  13  14\n");
printf("15  16  17  18  19  20  21\n");
printf("22  23  24  25  26  27  28\n");
printf("29  30  31\n");
}
else if (month == 4 || month == 6 || month == 9 || month == 11)//4 6 9 11月的日历
{
//printf("其他月份\n");
printf("1  2  3  4  5  6 7\n");
printf("8  9  10  11  12  13  14\n");
printf("15  16  17  18  19  20  21\n");
printf("22  23  24  25  26  27  28\n");
printf("29  30\n");
}
else//2月的日历
{
printf("1  2  3  4  5  6 7\n");
printf("8  9  10  11  12  13  14\n");
printf("15  16  17  18  19  20  21\n");
printf("22  23  24  25  26  27  28\n");
}
}
month++;
}
}

void CalculateDay(int year,int month,int day)//计算天数
{
//int year;
//int month;
//int day;
//printf("请输入要查询的日期\n");
//scanf("%d/%d/%d", &year, &month, &day);
time_t t;
struct tm *local;
time(&t);
local = localtime(&t);
int ThisYear = 1900 + local->tm_year;
int ThisDay = local->tm_mday;
int ThisWeek = local->tm_wday;
int Next1ThisYear = ThisYear - 1;//现实时间大
int Next2ThisYear = ThisYear + 1;//现实时间小
int ThisMonth = 1 + local->tm_mon;
int Next1ThisMonth = ThisMonth - 1;
int Next2ThisMonth = ThisMonth + 1;
int Next1Month = month + 1;
int Next2Month = month - 1;
int TotalGapDay = 0;
int TotalGapLeapYear = 0;
int TotalGapYear = 0;
int BigMonth = 0;
int LittleMonth = 0;
int SecondMonth = 0;
int WeekResult = 0;
int RetMonth = 0;
int InputDay = 0;
int InputThisDay = 0;
int LeapSecondMonth = 0;
int NotLeapSecondMonth = 0;
if (Next1ThisYear >= year)
{
while (Next1ThisYear > year)
{
int ret;
ret = JudgeLeapYear(Next1ThisYear);
if (ret == 1)
{
TotalGapLeapYear++;
}
else
{
TotalGapYear++;
}
Next1ThisYear--;
}
}
else
{
while (Next2ThisYear < year)
{
int ret;
ret = JudgeLeapYear(Next2ThisYear);
if (ret == 1)
{
TotalGapLeapYear++;
}
else
{
TotalGapYear++;
}
Next2ThisYear++;
}
}
while (Next1ThisMonth >= 1 && year<ThisYear)
{
while (year < ThisYear&&Next1Month <= 12)//输入不是本年的月份情况
{
if (Next1Month == 1 || Next1Month == 3 || Next1Month == 5 || Next1Month == 7
|| Next1Month == 8 || Next1Month == 10 || Next1Month == 12)
{
BigMonth++;
}
else if (Next1Month == 4 || Next1Month == 6 || Next1Month == 9 || Next1Month == 11)
{
LittleMonth++;
}
else
{
int ret = 0;
ret = JudgeLeapYear(year);
if (ret == 1)
{
LeapSecondMonth++;
}
else
{
NotLeapSecondMonth++;
}

}
Next1Month++;
}
if (Next1ThisMonth == 1 || Next1ThisMonth == 3 || Next1ThisMonth == 5 || Next1ThisMonth == 7
|| Next1ThisMonth == 8 || Next1ThisMonth == 10 || Next1ThisMonth == 12)
{
BigMonth++;
}
else if (Next1ThisMonth == 4 || Next1ThisMonth == 6 || Next1ThisMonth == 9 || Next1ThisMonth == 11)
{
LittleMonth++;
}
else
{
int ret = 0;
ret = JudgeLeapYear(ThisYear);
if (ret == 1)
{
LeapSecondMonth++;
}
else
{
NotLeapSecondMonth++;
}
}
Next1ThisMonth--;
}
while (Next2Month >= 1 && year > ThisYear)
{
while (year >ThisYear&&Next2ThisMonth <= 12)//不是本年输入年份的月份情况
{
if (Next2ThisMonth == 1 || Next2ThisMonth == 3 || Next2ThisMonth == 5 || Next2ThisMonth == 7
|| Next2ThisMonth == 8 || Next2ThisMonth == 10 || Next2ThisMonth == 12)
{
BigMonth++;
}
else if (Next2ThisMonth == 4 || Next2ThisMonth == 6 || Next2ThisMonth == 9
|| Next2ThisMonth == 11)
{
LittleMonth++;
}
else
{
int ret = 0;
ret = JudgeLeapYear(ThisYear);
if (ret == 1)
{
LeapSecondMonth++;
}
else
{
NotLeapSecondMonth++;
}
}
Next2ThisMonth++;
}
if (Next2Month == 1 || Next2Month == 3 || Next2Month == 5 || Next2Month == 7
|| Next2Month == 8 || Next2Month == 10 || Next2Month == 12)
{
BigMonth++;
}
else if (Next2Month == 4 || Next2Month == 6 || Next2Month == 9 || Next2Month == 11)
{
LittleMonth++;
}
else
{
int ret = 0;
ret = JudgeLeapYear(year);
if (ret == 1)
{
LeapSecondMonth++;
}
else
{
NotLeapSecondMonth++;
}
}
Next2Month--;
}

if (year == ThisYear)
{
if (month > ThisMonth)
{
while (Next2Month > ThisMonth)
{
if (Next2Month == 1 || Next2Month == 3 || Next2Month == 5 || Next2Month == 7
|| Next2Month == 8 || Next2Month == 10 || Next2Month == 12)
{
BigMonth++;
}
else if (Next2Month == 4 || Next2Month == 6 || Next2Month == 9 || Next2Month == 11)
{
LittleMonth++;
}
else if (Next2Month == 2)
{
int 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值