设为首页 加入收藏

TOP

教你如何用C语言实现的一个万年历(一)
2017-12-29 06:06:41 】 浏览:65
Tags:何用 语言 实现 一个万年历
该程序简单地输入一个年份(1901年之后的年份),随后程序输出该年份十二个月的日历。
#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_weekday = Tues;

int known_year = 1901;

int konwn_month = 1;

int known_day = 1;

int day_count(int month)

{

switch(month)

{

case 1: return 0;break;

case 2: return first1month;break;

case 3: return first2month;break;

case 4: return first3month;break;

case 5: return first4month;break;

case 6: return first5month;break;

case 7: return first6month;break;

case 8: return first7month;break;

case 9: return first8month;break;

case 10: return first9month;break;

case 11: return first10month;break;

case 12: return first11month;break;

}

}

/*char * month_name(int month)

{

switch(month)

{

case 1:

return "January";

break;

case 2:

return "February";

break;

case 3:

return "March";

break;

case 4:

return "April";

break;

case 5:

return "May";

break;

case 6:

return "June";

break;

case 7:

return "July";

break;

case 8:

return "August";

break;

case 9:

return "September";

break;

case 10:

return "October";

break;

case 11:

return "November";

break;

case 12:

return "December";

break;

default:

break;

}

}*/

char * month_name(int month)

{

switch(month)

{

case 1:

return "一月";

break;

case 2:

return "二月";

break;

case 3:

return "三月";

break;

case 4:

return "四月";

break;

case 5:

return "五月";


编程开发网
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C语言代码实现的万年历计算 下一篇C语言结构体基础练习

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

最新文章

热门文章

C 语言

C++基础

windows编程基础

linux编程基础

C/C++面试题目