C語言實現的乙個萬年曆小程式

2022-10-04 04:24:09 字數 2961 閱讀 3832

該程式簡單地輸入乙個年份(2023年之後的年份),隨後程式輸出該年份十二個月的日曆。

#include

#define mon 1

#define tues 2

#define wed 3

#define thur 4

#define fri 5

#define sat 6

#define sun 0

#define january_days 31

#define february_days 28

#define march_days 31

#define april_days 30

#define may_days 31

#define june_days 30

#define july_days 31

#define august_days 31

#define september_days 30

#define october_days 31

#define november_days 30

#define december_days 31

#define first1month january_days

#define first2month january_days+february_days

#define first3month january_days+february_days+march_days

#define first4month january_days+february_days+march_days+april_days

#define first5month january_days+february_days+march_days+april_days+may_days

#define first6month january_days+february_days+march_days+april_days+may_days+june_days

#define first7month january_days+february_days+march_days+april_days+may_days+june_days \

+july_days

#define first8month january_days+february_days+march_days+april_days+may_days+june_days \

+july_days+august_days

#define first9month january_days+february_days+march_days+april_days+may_days+june_days \

+july_days+august_days+september_days

#define first10month january_days+february_days+march_days+april_days+may_days+june_days \

+july_days+august_days+september_days+october_days

#define first11month january_days+february_days+march_days+april_days+may_days+june_days \

+july_days+august_days+september_days+october_days+november_days

int known_weekd程式設計客棧ay = tues;

int known_year = 1901;

int konwn_month = 1;

int known_day = 1;

int day_count(int month)

}/*char * month_name(int month)

}*/char * month_name(int month)

}/*按格式列印某年某月名稱*/

void first_line_print(int month, int year)

/*按格式列印星期名稱*/

void week_print()

/*計算該年該月份與已知日子之間的距離天數*/

int date_distance_count(int month, int year)

} }else

if (year == known_year) }

distance = (year - known_year)*365 + leap_year_count + day_count(month);

return distance;

}/*確定該月份第一天是星期幾*/

int makesure_firstday_weekday(int month, int year)

/*依次列印出該月份的日子*/

void print_in_turn(int month, int firstday, int year)

switch(month)

}break;

} case 2:

}break;

}else /*平年*/

}break;}}

case 4:

case 6:

case 9:

case 11:

}break;

} }}

void date_print(int month, int year)

void main_month(int month, int year)

void main_calendar(int year)

}int main()

main_calendar(year);

scanf(" ");

return 0;

}執行效果圖:

本文標題: c語言實現的乙個萬年曆小程式

本文位址:

C語言實現萬年曆

c語言實現萬年曆 摘要 介紹使用c語言實現萬年曆的列印與輸出。關鍵字 c 萬年曆 列印與輸出 一 引言 萬年曆是我們日常生活中經常用到的一種非常實用的工具。由於工作繁忙,人們常常忘記某一天是星期幾,或者想快速地查詢某一年中某一天是星期幾,這裡萬年曆就能派上用場了。本文將介紹一種萬年曆的實現方法,通過...

c 萬年曆小程式

include include include include include using namespace std class date 定義乙個日期類 建構函式 void setyear int y 改變年份的介面 void setmonth int m 改變月份的介面 void setday...

萬年曆 C語言

顯示效果 大概步驟 1.顯示主介面 void showmenu char temp 10 2.判斷是否為閏年 bool isleap int year 3.計算總天數 int daysum int year,int month 4.顯示日曆 showcalendar int sum,int year...