开发工具:
文件大小: 169kb
下载次数: 0
上传时间: 2015-04-30
详细说明: #include #include #include int g MonthDays[13] {0 31 28 31 30 31 30 31 31 30 31 30 31}; 定义全局数组 函数声明 int LeapYear int n ; 判断闰年与否 int CountYearDays int year ; 计算从公元1 1到某年12 31一共多少天 int CountMonthDays int month ; 计算某年一月一日到12月31日的天数 void Menu void ; 输出系统提供的功能选项 提示用户进行选择 void ListMonth int days int t ; 用来按规定格式输出一个月的日历 void Search1 void ; 用来显示一年12个月的日历 void Search2 void ; 用来显示某年某个月的日历 void Search3 void ; 用来显示某天是星期几 void main { int selec t; while 1 { Menu ; 功能选择 scanf "%d" &select ; switch select { case 1:Search1 ;break; select 1 case 2:Search2 ;break; case 3:Search3 ;break; case 0:printf " n t谢谢使用 再见 n" ;exit 0 ; default:printf " n t按键错误 请重新选择 n" ; } } } 功能:判断闰年 参数:n为需要判断的年份 返回:是闰年返回1 不是返回0 主要思路:用if语句判断某一年是否为闰年 int LeapYear int n { if n%4 0&&n0 0 ||n%400 0 return 1 ; else return 0 ; } 功能:计算从公元元年到公元(year 1)年的总天数 参数:Year为年份 返回:总天数 主要思路:用for循环计算天数 int CountYearDays int year { int i flag days 0; for i 1;i2 { mdays++; } else if month 2 days 29; } alldays ydays+mdays+1; t alldays%7; printf " n %d年%d月 n n" year month ; ListMonth days t ; printf " n" ; } 功能:输出某一天是星期几 参数:无 返回:无 主要思路:通过调用函数计算天数 在计算并输出这一天是星期几 void Search3 void { int t year month day flag ydays mdays alldays; printf "请输入年月日(如2004 4 3):" ; scanf "%d %d %d" &year &month &day ; ydays CountYearDays year ; mdays CountMonthDays month ; flag LeapYear year ; if flag&&month>2 { mdays++; } alldays ydays+mdays+day; t alldays%7; printf " n %d年%d月%d日:" year month day ; switch t { case 0:printf "星期日" ;break; case 1:printf "星期一" ;break; case 2:printf "星期二" ;break; case 3:printf "星期三" ;break; case 4:printf "星期四" ;break; case 5:printf "星期五" ;break; case 6:printf "星期六" ;break; }; }">#include #include #include int g MonthDays[13] {0 31 28 31 30 31 30 31 31 30 31 30 31}; 定义全局数组 函数声明 int LeapYear int n ; 判断闰年与否 int CountYearDays int year ; 计算从公元1 1到某年12 31一共多少天 int [更多] ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.