搜索
首页 电脑/网络 程序设计 C/C++

用C语言建立一个小型日历系统 求救呀!

要求: (1)判断是否是闰年 (2)给定某年的某一天能判断是星期几 (3)给定某月的某个星期几能判断出是几月几号 (4)给定某一年能打印出全年的日历

全部回答

2004-12-14

0 0

    基本思路就是利用time。h中的结构和变量进行日期的转换与计算,这里涉及到一个结构变量tm和一个time_t变量(实际为长整型)。 (1)判断是否为闰年很简单,就是年份能被4整除而且不能被400整除的就是闰年。
   (2)给出一段示范代码 int iYear, iMonth, iDay; printf("please input the year(>=1900), the month(1-12), the date(1-31): "); scanf("%d %d %d", &iYear, &iMonth, &iDay); struct tm struct_time = {0}; struct_ _year = iYear - 1900; struct_ _mon = iMonth - 1; struct_ _mday = iDay; time_t ttime; ttime = mktime(&struct_time); //转换 struct_time = *localtime(&ttime); printf("%d\n", struct_ _wday); //输出星期几,0为周日 printf("%s\n", asctime(&struct_time)); //以字符串形式输出日期 理解了之后,(3)和(4)也就轻而易举了。
     。

2004-12-16

35 0

C语言的书上就有

类似问题换一批

热点推荐

热度TOP

相关推荐
加载中...

热点搜索 换一换

电脑/网络
C/C++
程序设计
电脑装机
操作系统/系统故障
硬件
笔记本电脑
百度
互联网
反病毒
软件
程序设计
C/C++
数据库
VB
JAVA相关
C#/.NET
VC++
汇编语言
其他编程语言
C/C++
C/C++
举报
举报原因(必选):
取消确定举报