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

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

#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 ret = 0;

ret = JudgeLeapYear(year);

if (ret == 1)

{

LeapSecondMonth++;

}

else

{

NotLeapSecondMonth++;

}

}

Next2Month--;

}

}

else if (month < ThisMonth)

{

while (Next1Month < ThisMonth)

{

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 if (Next1Month == 2)

{

int ret = 0;

ret = JudgeLeapYear(year);

if (ret == 1)

{

LeapSecondMonth++;

}

else

{

NotLeapSecondMonth++;

}

}

Next1Month++;

}

}

else

{

if (day >= ThisDay)

{

printf("同年同一个月,相差%d天\n", day - ThisDay);

TotalGapDay = day - ThisDay;

if (TotalGapDay % 7 == 0)

{

WeekResult = ThisWeek;

}

else

{

if ((TotalGapDay % 7 + ThisWeek) <= 7)

{

WeekResult = TotalGapDay % 7 + ThisWeek;

}

else

{

WeekResult = TotalGapDay % 7 + ThisWeek - 7;

}

}

printf("今天是星期%d\n", WeekResult);

return;

}

else

{

printf("同年同一个月,相差%d天\n", ThisDay - day);

TotalGapDay = ThisDay - day;

if (TotalGapDay % 7 == 0)

{

WeekResult = ThisWeek;

}

else

{

if ((ThisWeek - TotalGapDay % 7) >= 0)

{

WeekResult = ThisWeek - TotalGapDay % 7;

}

else

{

WeekResult = 7 - TotalGapDay % 7 + ThisWeek;

}

}

printf("今天是星期%d\n", WeekResult);

return;

}

}

}

if (year < ThisYear)

{

InputThisDay = ThisDay;

RetMonth = JudgeMonth(month);

if (RetMonth == 1)

{

InputDay = 31 - day;

}

else if (RetMonth == 0)

{

InputDay = 30 - day;

}

else

{

int ret = JudgeLeapYear(year);

if (ret == 1)

{

InputDay = 29 - day;

}

else

{

InputDay = 28 - day;

}

}

}

else if (year > ThisYear)

{

InputDay = day;

RetMonth = JudgeMonth(ThisMonth);

if (RetMonth == 1)

{

InputThisDay = 31 - ThisDay;

}

else if (RetMonth == 0)

{

InputThisDay = 30 - ThisDay;

}

else

{

int ret = JudgeLeapYear(ThisYear);

if (ret == 1)

{

InputThisDay = 29 - ThisDay;

}

else

{

InputThisDay = 28 - ThisDay;

}

}

}

else

{

if (month < ThisMonth)

{

InputThisDay = ThisDay;

RetMonth = JudgeMonth(month);

if (RetMonth == 1)

{

InputDay = 31 - day;

}

else if (RetMonth == 0)

{

InputDay = 30 - day;

}

else

{

int ret = JudgeLeapYear(year);

if (ret == 1)

{

InputDay = 29 - day;

}

else

{

InputDay = 28 - day;

}

}

}

else if (month > ThisMonth)

{

InputDay = day;

RetMonth = JudgeMonth(ThisMonth);

if (RetMonth == 1)

{

InputThisDay = 31 - ThisDay;

}

else if (RetMonth == 0)

{

InputThisDay = 30 - ThisDay;

}

else

{

int ret = JudgeLeapYear(year);

if (ret == 1)

{

InputThisDay = 29 - ThisDay;

}

else

{

InputThisDay = 28 - ThisDay;

}

}

}

}

TotalGapDay = TotalGapYear * 365 + TotalGapLeapYear * 366 + BigMonth * 31 + LittleMonth * 30 + LeapSecondMonth * 29 + NotLeapSecondMonth * 28 + InputThisDay + InputDay;

printf("相差%d天\n", TotalGapDay);

}

int JudgeMonth(int month)//判断月份

{

int ret = 0;

if (month == 1 ||month == 3 ||month == 5 || month == 7

|| month == 8 || month == 10 || month == 12)

{

ret = 1;

return ret;

}

else if (month == 4 || month == 6 || month == 9 || month == 11)

{

return ret;

}

else

{

ret = -1;

return ret;

}

}

int JudgeLeapYear(int year)//判断是否为闰年

{

int ret=0;

if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))

{

ret = 1;

return ret;

}

else

{

return ret;

}

}

void ReturnMenu()//回主菜单

{

CalendarTable();

}

void ShowData()//显示当前日期

{

struct tm *local;

time_t t;

t = time(NULL);

local = localtime(&t);

printf("%d", 1900 + local->tm_year);

printf("/");

printf("%d", 1 + local->tm_mon);

printf("/");

printf("%d\n", local->tm_mday);

}

void ShowTime()//显示当前时间

{

struct tm *local;

time_t t;

t = time(NULL);

local = localtime(&t);//local->tm_hour, local->tm_min, local->tm_sec

printf("%d:", local->tm_hour);

printf("%d:", local->tm_min);

printf("%d\n", local->tm_sec);

}

void ShowDataTime()//显示日期时间

{

struct tm *local;

time_t t;

t = time(NULL);

local = localtime(&t);

printf("%d:", local->tm_hour);

printf("%d:", local->tm_min);

printf("%d\n", local->tm_sec);

printf("%d", 1900 + local->tm_year);

printf("/");

printf("%d", 1 + local->tm_mon);

printf("/");

printf("%d\n", local->tm_mday);

}

void ShowDynamicTime()//动态显示时间

{

while (1)

{

time_t t;

struct tm *local;

time(&t);

local = localtime(&t);

printf("%d/%d/%d %d:%d:%d\n", 1900 + local->tm_year, 1 + local->tm_mon,

local->tm_mday, local->tm_hour, local->tm_min, local->tm_sec);

Sleep(1000);

}

}

void ShowMonth()//显示本月日历表

{

time_t t;

struct tm *local;

time(&t);

local = localtime(&t);

int ThisYear = 1900+local->tm_year;

printf("%d\n", ThisYear);

int ThisMonth = 1 + local->tm_mon;

if ((ThisYear %4 == 0 && ThisYear %100 != 0)||(ThisYear % 400 == 0))//是闰年

{

printf("是闰年\n");

printf("************************\n");

printf("本月日历\n");

if (ThisMonth == 1 || ThisMonth == 3 || ThisMonth == 5 || ThisMonth == 7 || ThisMonth == 8 || ThisMonth == 10 || ThisMonth == 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 (ThisMonth == 4 || ThisMonth == 6 || ThisMonth == 9 || ThisMonth == 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 (ThisMonth == 1 || ThisMonth == 3 || ThisMonth == 5 || ThisMonth == 7 || ThisMonth == 8 || ThisMonth == 10 || ThisMonth == 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 (ThisMonth == 4 || ThisMonth == 6 || ThisMonth == 9 || ThisMonth == 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");

}

}

}

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

void CheckWeek()//查询***是星期几

{

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 ret = 0;

ret = JudgeLeapYear(year);

if (ret == 1)

{

LeapSecondMonth++;

}

else

{

NotLeapSecondMonth++;

}

}

Next2Month--;

}

}

else if (month < ThisMonth)

{

while (Next1Month < ThisMonth)

{

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 if (Next1Month == 2)

{

int ret = 0;

ret = JudgeLeapYear(year);

if (ret == 1)

{

LeapSecondMonth++;

}

else

{

NotLeapSecondMonth++;

}

}

Next1Month++;

}

}

else

{

if (day >= ThisDay)

{

printf("同年同一个月,相差%d天\n", day - ThisDay);

TotalGapDay = day - ThisDay;

if (TotalGapDay % 7 == 0)

{

WeekResult = ThisWeek;

}

else

{

if ((TotalGapDay % 7 + ThisWeek) <= 7)

{

WeekResult = TotalGapDay % 7 + ThisWeek;

}

else

{

WeekResult = TotalGapDay % 7 + ThisWeek - 7;

}

}

printf("今天是星期%d\n", WeekResult);

return;

}

else

{

printf("同年同一个月,相差%d天\n", ThisDay - day);

TotalGapDay = ThisDay - day;

if (TotalGapDay % 7 == 0)

{

WeekResult = ThisWeek;

}

else

{

if ((ThisWeek - TotalGapDay % 7) >= 0)

{

WeekResult = ThisWeek - TotalGapDay % 7;

}

else

{

WeekResult = 7 - TotalGapDay % 7 + ThisWeek;

}

}

printf("今天是星期%d\n", WeekResult);

return;

}

}

}

if (year < ThisYear)

{

InputThisDay = ThisDay;

RetMonth = JudgeMonth(month);

if (RetMonth == 1)

{

InputDay = 31 - day;

}

else if (RetMonth == 0)

{

InputDay = 30 - day;

}

else

{

int ret = JudgeLeapYear(year);

if (ret == 1)

{

InputDay = 29 - day;

}

else

{

InputDay = 28 - day;

}

}

}

else if (year > ThisYear)

{

InputDay = day;

RetMonth = JudgeMonth(ThisMonth);

if (RetMonth == 1)

{

InputThisDay = 31 - ThisDay;

}

else if (RetMonth == 0)

{

InputThisDay = 30 -ThisDay;

}

else

{

int ret = JudgeLeapYear(ThisYear);

if (ret == 1)

{

InputThisDay = 29 - ThisDay;

}

else

{

InputThisDay = 28 - ThisDay;

}

}

}

else

{

if (month < ThisMonth)

{

InputThisDay = ThisDay;

RetMonth = JudgeMonth(month);

if (RetMonth == 1)

{

InputDay = 31 - day;

}

else if (RetMonth == 0)

{

InputDay = 30 - day;

}

else

{

int ret = JudgeLeapYear(year);

if (ret == 1)

{

InputDay = 29 - day;

}

else

{

InputDay = 28 - day;

}

}

}

else if (month > ThisMonth)

{

InputDay = day;

RetMonth = JudgeMonth(ThisMonth);

if (RetMonth == 1)

{

InputThisDay = 31 - ThisDay;

}

else if (RetMonth == 0)

{

InputThisDay = 30 - ThisDay;

}

else

{

int ret = JudgeLeapYear(year);

if (ret == 1)

{

InputThisDay = 29 - ThisDay;

}

else

{

InputThisDay = 28 - ThisDay;

}

}

}

}

TotalGapDay = TotalGapYear * 365 + TotalGapLeapYear * 366 + BigMonth * 31 + LittleMonth * 30 + LeapSecondMonth * 29+NotLeapSecondMonth*28 + InputThisDay + InputDay;

printf("相差%d天\n", TotalGapDay);

if (year < ThisYear)

{

if (TotalGapDay % 7 == 0)

{

WeekResult = ThisWeek;

}

else

{

if ((ThisWeek - TotalGapDay % 7) >= 0)

{

WeekResult = ThisWeek - TotalGapDay % 7;

}

else

{

WeekResult = 7 - TotalGapDay % 7 + ThisWeek;

}

}

printf("今天是星期%d\n", WeekResult);

}

else

{

if (TotalGapDay % 7 == 0)

{

WeekResult = ThisWeek;

}

else

{

if ((TotalGapDay % 7 + ThisWeek) <= 7)

{

WeekResult = TotalGapDay % 7 + ThisWeek;

}

else

{

WeekResult = TotalGapDay % 7 + ThisWeek - 7;

}

}

printf("今天是星期%d\n", WeekResult);

}

}

void CheckWeekLater()//查询***几天之后是星期几

{

time_t t;

struct tm *local;

time(&t);

local = localtime(&t);

int ThisWeek = local->tm_wday;

int LaterTotalGapDay = 0;

int WeekResult = 0;

printf("输入今天后的天数\n");

scanf("%d", &LaterTotalGapDay);

if (LaterTotalGapDay % 7 == 0)

{

WeekResult = ThisWeek;

}

else

{

if ((LaterTotalGapDay % 7 + ThisWeek) <= 7)

{

WeekResult = LaterTotalGapDay % 7 + ThisWeek;

}

else

{

WeekResult = LaterTotalGapDay % 7 + ThisWeek - 7;

}

}

printf("今天是星期%d\n", WeekResult);

}

void CheckWeekBefore()//查询***几天之前是星期几

{

time_t t;

struct tm *local;

time(&t);

local = localtime(&t);

int ThisWeek = local->tm_wday;

int BeforeTotalGapDay = 0;

int WeekResult = 0;

printf("输入今天前的天数:\n");

scanf("%d", &BeforeTotalGapDay);

if (BeforeTotalGapDay % 7 == 0)

{

WeekResult = ThisWeek;

}

else

{

if ((ThisWeek - BeforeTotalGapDay % 7) >= 0)

{

WeekResult = ThisWeek - BeforeTotalGapDay % 7;

}

else

{

WeekResult = 7 - BeforeTotalGapDay % 7 + ThisWeek;

}

}

printf("今天是星期%d\n", WeekResult);

}

void CheckMonth()//查询***月的日历表

{

int year;

int month;

int ReturnYear;

int ReturnMonth;

printf("输入某年份的某月:");

scanf("%d%d",&year,&month);

ReturnMonth = JudgeMonth(month);

if (ReturnMonth == 1)

{

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 (ReturnMonth == 0)

{

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

{

ReturnYear = JudgeLeapYear(year);

if (ReturnYear == 1)

{

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("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");

}

}

}

void CheckYear()//查询***年的日历表

{

int year;

printf("输入要显示的年份:\n");

scanf("%d",&year);

ShowEveryMonth(year);

}

void CheckDays()//查询***距离现在多少天

{

int year;

int month;

int day;

printf("请输入要查询的日期\n");

scanf("%d/%d/%d", &year, &month, &day);

CalculateDay(year, month, day);

}

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

void LastMonth()//上一个月

{

time_t t;

struct tm *local;

time(&t);

local = localtime(&t);

int ThisMonth = 1+local->tm_mon;

int ThisYear = 1900+local->tm_year;

if (ThisMonth > 1)

{

int NextMonth = ThisMonth - 1;

int ReturnMonth = JudgeMonth(NextMonth);

if (ReturnMonth == 1)

{

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 (ReturnMonth == 0)

{

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

{

int ReturnYear = JudgeLeapYear(ThisYear);

if (ReturnYear == 1)

{

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("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");

}

}

}

else if (ThisMonth == 1)

{

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");

}

}

void NextMonth()//下一个月

{

time_t t;

struct tm *local;

time(&t);

local = localtime(&t);

int ThisMonth = 1+local->tm_mon;

int ThisYear = 1900+local->tm_year;

if (ThisMonth <12)

{

int NextMonth = ThisMonth+1;

int ReturnMonth = JudgeMonth(NextMonth);

if (ReturnMonth == 1)

{

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 (ReturnMonth == 0)

{

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

{

int ReturnYear = JudgeLeapYear(ThisYear);

if (ReturnYear == 1)

{

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("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");

}

}

}

else if (ThisMonth == 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");

}

}

void LastYear()//上一年

{

time_t t;

struct tm *local;

time(&t);

local = localtime(&t);

int ThisYear = 1900 + local->tm_year;

int NextYear = ThisYear - 1;

ShowEveryMonth(NextYear);

}

void NextYear()//下一年

{

time_t t;

struct tm *local;

time(&t);

local = localtime(&t);

int ThisYear = 1900 + local->tm_year;

int NextYear = ThisYear + 1;

ShowEveryMonth(NextMonth);

}

void SaveCalendar()//保存当前日历

{

time_t t;

struct tm *local;

time(&t);

local = localtime(&t);

int ThisYear = 1900 + local->tm_year;

int ThisMonth = 1 + local->tm_mon;

int ThisDay = local->tm_mday;

FILE *fOut;

char strYear[15] = {‘a‘};

char strMonth[3]={‘a‘};

char strDay[3] = {‘a‘};

int i = 0;

int n = 0;

_itoa(ThisYear, strYear, 10);

_itoa(ThisMonth, strMonth, 10);

_itoa(ThisDay, strDay, 10);

strcat(strYear, strMonth);

strcat(strYear, strDay);

n = strlen(strYear);

if ((fOut = fopen("rili.txt", "w")) != NULL)

{

for (i = 0; i < n;i++)

{

fputc(strYear[i], fOut);

}

fputc(‘\0‘, fOut);

printf("日期保存成功\n");

}

else

{

printf("打开文件失败\n");

}

fclose(fOut);

}

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

void AddMemorandum()//添加备忘录信息

{

int count = 0;

char message[30];

char data[10];

int i = 0;

int k = 0;

FILE *fOut=fopen("beiwang.txt","wb");

printf("是否要添加\n");

while (1)

{

scanf("%d", &i);

if (i == 1)

{

printf("请输入添加备忘录的信息:\n");

scanf("%s", data);

scanf("%s", message);

int LenData = strlen(data)+1;

int LenMessage = strlen(message)+1;

int j = 0;

if (fOut!= NULL)

{

for (j = 0; j < LenData; j++)

{

fputc(data[j], fOut);

}

fputc(‘\n‘,fOut);

for (j = 0; j < LenMessage; j++)

{

fputc(message[j], fOut);

}

fputc(‘\n‘, fOut);

}

else

{

printf("打开文件失败\n");

}

count++;

printf("成功添加一个备忘录\n");

}

else

{

fclose(fOut);

printf("不再添加\n");

break;

}

}

}

void DelateMemorandum()//删除备忘录信息

{

FILE *fIn = fopen("beiwang.txt", "wb");

if (fIn != NULL)

{

remove("beiwang.txt");

}

else

{

printf("打开文件失败\n");

}

fclose(fIn);

}

void ChangeMemorandum()//更改备忘录信息

{

FILE *fOut = fopen("output.txt", "wb");

FILE *fIn = fopen("beiwang.txt", "rb");

char str[10];

printf("输入要修改备忘录的日期:\n");

scanf("%s",str);

if (fOut == NULL || fIn == NULL)

{

printf("打开文件失败\n");

}

else

{

char message[100];

while (fgets(message,100,fIn))

{

int ret = 1;

ret = strcmp(str, message);

if (ret == 0)

{

int i = 0;

printf("修改本天的备忘信息:\n");

char NewStr[100];

scanf("%s", NewStr);

fputs(message, fOut);

fgets(message, 100, fIn);

while (NewStr[i] != ‘\0‘)

{

fputc(NewStr[i],fOut);

i++;

}

fputc(‘\0‘, fOut);

}

else

{

fputs(message, fOut);

fgets(message, 100, fIn);

fputs(message, fOut);

}

}

}

fclose(fIn);

fclose(fOut);

}

void CheckMemorandum()//查询备忘录信息

{

FILE *fIn = fopen("beiwang.txt", "rb");

char str[100];

char CheckStr[10];

scanf("%s", CheckStr);

if (fIn != NULL)

{

while (1)

{

int ret = 1;

fgets(str, 100, fIn);

ret = strcmp(CheckStr, str);

if (ret == 0)

{

fgets(str, 100, fIn);

printf("本天应该做的:");

printf("%s\n", str);

break;

}

else

{

if (fgets(str, 100, fIn) == NULL)

{

printf("本天没有备忘信息\n");

break;

}

else

{

}

}

}

}

else

{

printf("打开文件失败\n");

}

}

void ShowMemorandum()//展示备忘录信息

{

FILE *fIn = fopen("beiwang.txt", "rb");

char str[50];

while ((fgets(str, 50, fIn))!=NULL)

{

printf("%s\n", str);

}

}

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

void Memorandum()//日期备忘录

{

int k;

scanf_s("%d", &k);

switch (k)

{

case 1:

printf("添加备忘录信息\n");

AddMemorandum();

break;

case 2:

printf("删除备忘录信息\n");

DelateMemorandum();

break;

case 3:

printf("更改备忘录信息\n");

ChangeMemorandum();

break;

case 4:

printf("查询备忘录信息\n");

CheckMemorandum();

break;

case 5:

printf("备忘录信息展示\n");

ShowMemorandum();

break;

case 0:

printf("退出备忘录\n");

ReturnMenu();

break;

}

}

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

void AlterCalendarTable()//修改日历

{

int key1=0;

int key2 = 0;

key1 = getch();

key2 = getch();

switch (key2)

{

case 72:

printf("上一个月:\n");

LastMonth();

break;

case 80:

printf("下一个月:\n");

NextMonth();

break;

case 75:

printf("上一年:\n");

LastYear();

break;

case 77:

printf("下一年:\n");

NextYear();

break;

case 71:

printf("保存当前日历\n");

SaveCalendar();

break;

case 79:

printf("返回主菜单\n");

ReturnMenu();

break;

}

}

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

void CheckCalendarTable()//日历查询

{

int j;

scanf_s("%d",&j);

switch (j)

{

case 1:

printf("查询***是星期几\n");

CheckWeek();

break;

case 2:

printf("查询***几天之后是星期几\n");

CheckWeekLater();

break;

case 3:

printf("查询***几天之前是星期几\n");

CheckWeekBefore();

break;

case 4:

printf("查询***月的日历表\n");

CheckMonth();

break;

case 5:

printf("查询***年的日历表\n");

CheckYear();

break;

case 6:

printf("查询***距离现在多少天\n");

CheckDays();

break;

case 0:

printf("返回主菜单\n");

ReturnMenu();

break;

}

}

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

void ShowCalendarTable()//日历显示

{

int m;

scanf_s("%d", &m);

switch (m)

{

case 1:

printf("显示当前日期\n");

ShowData();

break;

case 2:

printf("显示当前时间\n");

ShowTime();

break;

case 3:

printf("显示日期时间\n");

ShowDataTime();

break;

case 4:

printf("动态显示时间\n");

ShowDynamicTime();

break;

case 5:

printf("显示本月日历表\n");

ShowMonth();

break;

case 0:

printf("返回主菜单\n");

ReturnMenu();

break;

}

}

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

void HelpMessage()//信息帮助

{

char str1[] = "1的功能是显示相应的日历表,里面的不同键又可以实现更详细的功能";

char str2[] = "2的功能是查询相应的日历表,里面的不同键又可以实现更详细的功能";

char str3[] = "3的功能是修改相应的日历表,里面的不同键又可以实现更详细的功能";

char str4[] = "4的功能是日历表的备忘录,里面的不同键又可以实现更详细的功能";

char str5[] = "5的功能是信息帮助";

char str0[] = "0的功能是直接退出日历表";

FILE *fOut = fopen("HelpMessage.txt", "wb");

if (fOut == NULL)

{

printf("打开文件失败\n");

}

else

{

int i = 0;

while (str1[i] != ‘\0‘)

{

fputc(str1[i], fOut);

i++;

}

fputc(‘\n‘, fOut);

i = 0;

while (str2[i] != ‘\0‘)

{

fputc(str2[i], fOut);

i++;

}

fputc(‘\n‘, fOut);

i = 0;

while (str3[i] != ‘\0‘)

{

fputc(str3[i], fOut);

i++;

}

fputc(‘\n‘, fOut);

i = 0;

while (str4[i] != ‘\0‘)

{

fputc(str4[i], fOut);

i++;

}

fputc(‘\n‘, fOut);

i = 0;

while (str5[i] != ‘\0‘)

{

fputc(str5[i], fOut);

i++;

}

fputc(‘\n‘, fOut);

i = 0;

while (str0[i] != ‘\0‘)

{

fputc(str0[i], fOut);

i++;

}

fputc(‘\n‘, fOut);

fclose(fOut);

}

}

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

void CalendarTable()

{

int n;

scanf_s("%d", &n);

switch (n)

{

case 1:

printf("日历显示\n");

ShowCalendarTable();

break;

case 2:

printf("日历查询\n");

CheckCalendarTable();

break;

case 3:

printf("修改日历\n");

AlterCalendarTable();

break;

case 4:

printf("日历备忘录\n");

Memorandum();

break;

case 5:

printf("信息帮助\n");

HelpMessage();

break;

case 0:

printf("退出系统\n");

exit(0);

break;

}

}

只是实现了软解的各接口功能,要想有更好的用户体验还有改进的地方。

时间: 2024-11-05 14:59:05

万年历软件各个接口功能的实现的相关文章

Thinkphp集成手机支付宝接口功能

最近做微商城,需要实现手机wap支付功能,选择的是支付宝的接口支付功能.这里是我用的是支付宝“手机网站支付”产品(注:该产品要支付宝企业账号才能申请),具体步骤如下: 一.下载支付宝接口包 https://b.alipay.com/order/productDetail.htm?productId=2013080604609688 二.重新整理接口包文件 下载下来的接口包文件有很多语言的源码 注:openssl用来生成公私钥,RSA签名才使用.这里我们用的MD5签名,所有该文件用不到. 我们选择

手机进销存软件有哪些功能?

一款好用的手机进销存软件,不仅功能可以最大程度满足采购.销售.库存.财务等方面管理需求,还要在业务流程上,灵活适应企业复杂多变的业务需求.一款好用的手机进销存软件,可以在手机上实现客户.销售.采购.库存.产品.合同.售后.财务.OA等一体化管理,Android.iOS.Windows Phone全面支持,与电脑端.平板端数据实时同步,最大限度提升企业进货.销售.库存.财务的工作和管理效率.     1.功能三:外勤人员一体化管理 对企业而言,员工拜访客户.外地出差.上门维修.出门办事等,都不可避

Nagios和商业开源网管软件SugarNMS的功能介绍和区别

Nagios简介 Nagios是一个监视系统运行状态和网络信息的监视系统.Nagios能监视所指定的本地或远程主机以及服务,同时提供异常通知功能等.Nagios可运行在Linux/Unix平台之上,同时提供一个可选的基于浏览器的WEB界面以方便系统管理人员查看网络状态,各种系统问题,以及日志等等.Nagios通常由一个主程序(Nagios).一个插件程序(Nagios-plugins)和四个可选的ADDON(NRPE.NSCA.NSClient++和NDOUtils)组成.Nagios的监控工作

【经典】项目管理软件哪个好?项目管理软件6大功能须知

对项目型企业来说,项目管理是整个项目中最重要的过程之一.好的项目管理软件能帮企业把所有项目任务管得井然有序.那么,项目管理软件哪个好?项目管理软件有哪些功能呢?下面以市场上主流的项目管理软件系统为例进行说明,希望能为大家提供一些帮助.     一.项目管理软件哪个好? 项目管理软件既是一个管理软件,也是一个管理工具,还是信息科技与管理思想的融合体,是先进的项目管理思想借助电脑,来达成企业的项目管理目标.所以,项目管理软件哪个好?既与软件本身蕴含的管理思想和功能有关,也和企业自身管理需求和能力相关

从软件导入数据功能, 看人员沟通问题

从软件导入数据功能, 看人员沟通问题 1 . 对于兼容性不好, 容错性也不好的软件,     a. 在导入数据时, 只能按软件要求的格式及规则进行操作.  一个规则或者格式不对的数据,就无法导入系统,并不给出任何提示信息.      就想人与人沟通, 有些人只能接受按自己的思维及方式的语言. 一旦那点不同, 即油烟不进,也不反馈沟通中的问题.   2. 对于兼容性好, 容错性不好的软件,  3. 对于兼容性不好, 容错性好的软件,  4. 对于兼容性好, 容错性好的软件, 

微信公众平台多客服新增自定义客服头像和消息转发接口功能

多客服一般是开放给微信认证服务号的一个便捷功能,可以将消息转发到多客服方便回复.对有些“选择综合症“的客服,看到那一层不变的客服头像就想吐槽.现在好了,多客服新增自定义客服头像和接口功能,也可以自定义昵称 一.开通“多客服”的公众号可为客服工号配置自定义头像. 使用6.0.2版微信的用户在同公众号进行客服沟通时,可以看到配置的客服头像和昵称. 二.为满足公众号个性化客服需求,公众平台为开发者提供了“多客服”相关接口,可将消息转发到多客服 和 消息转发到指定客服. A:如果公众号处于开发模式,普通

高可用的作用,服务器虚拟化软件的常用功能

?高可用 高可用是资源池中的某些物理主机出现故障后,故障物理主机上的虚拟机会在资源池内其他正常的物理主机上启动,从而保障资源池安全可靠的持续运行,是服务器虚拟化软件的常见功能. 配置高可用的前提是使用共享存储部署虚拟机镜像,启用高可用后,当系统检测到主机故障时,系统将根据配置信息,将故障虚拟机在正常的计算节点上重新创建.高可用有如下配置选项,用户可根据自己的实际业务和组网,配置不同规则保证最大限度的业务连续性. 设置最大物理主机故障数 当资源池故障物理主机数量超过设置值时,故障物理主机上的虚拟机

mathematica12软件的新增功能有哪些?

mathematica12软件中文版更新了,想要知道mathematica12软件的新增功能有哪些?下面一起来看看吧:点击安装 # mathematica12软件的新增功能 符号与数值计算-渐近-微积分-代数-凸优化-非线性有限元 可视化与图形-核心可视化-标签可视化-复数的可视化-地理可视化几何与地理 -几何计算-多边形和多面体-非线性有限元-高中几何-地理计算的新功能 数据科学与计算-不确定性.单位和日期-概率和统计-图和网络-数据导入和导出 图像与音频-图像计算-音频计算-显微镜图像计算-

SOAP WebService接口功能自动化测试

百度搜索:小强测试品牌 QQ群:522720170 本节内容节选自<小强软件测试疯狂讲义>一书 此处我们以qqCheckOnline的WebService接口为例进行讲解,接口的具体信息如下: l 接口描述:获得腾讯QQ在线状态 l 入参:qqCode,String类型,默认QQ号码:8698053 l 出参:qqCheckOnlineResult,String类型 返回数据代表的含义为:Y = 在线:N = 离线:E = QQ号码错误:A = 商业用户验证失败:V = 免费用户超过数量 l