- 1、本文档共8页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
C 程序设计-万年历课程设计报告
C++程序设计-万年历课程设计报告
#include
#include
using namespace std;
int monthday int year,int month ;
int newdays int year ;
//输出日历表
int output int year
int i,j,k,n;
int firstmonthday[12];
char month[12][10] 一月 , 二月 , 三月 , 四月 , 五月 , 六月 , 七月 , 八月 , 九月 , 十月 , 十一月 , 十二月 ;
char weekday[] 日 一 二 三 四 五 六 ;
for i 0;i 12;i++
if i 0
firstmonthday[i] newdays year ;
else
firstmonthday[i] firstmonthday[i-1]+monthday year,i %7;
int month1[6][7],month2[6][7],month3[6][7];
cout year 年 endl;
for i 0;i 12;i+ 2
cout setw 4 month[i] setw 17 \t setw 4 month[i+1] endl;
cout weekday \t weekday endl;
for j 0;j 6;j++
for k 0;k 7;k++
month1[j][k] k+1-firstmonthday[i]+j*7;
month2[j][k] k+1-firstmonthday[i+1]+j*7;
for n 0;n 7;n++
if month1[j][n] 1||month1[j][n] monthday year,i+1
cout ;
else
cout setw 3 month1[j][n];
cout \t;
for n 0;n 7;n++
if month2[j][n] 1||month2[j][n] monthday year,i+2
cout ;
else
cout setw 3 month2[j][n];
cout \n;
return 0;
//判断某年某月的天数
int monthday int year,int month
int d;
switch month
case 1:case 3:case 5:case 7:case 8:case 10:case 12:d 31;break;
case 4:case 6:case 9:case 11:d 30;break;
case 2:
if year%4 0 year%100! 0 || year%400 0 d 29;
else d 28;
return d;
//判断元旦的星期几
int newdays int year
int day;
if year%4 0 year%100! 0 || year%400 0
day year-1+ year/4 - year/100 + year/400 %7;
else
day year+ year/4 - year/100 + year/400 %7;
return day;
//主函数实现
int main
int year;
char choose;
n
文档评论(0)