怎么用C++实现简易万年历
发表于:2024-10-01 作者:千家信息网编辑
千家信息网最后更新 2024年10月01日,本篇内容主要讲解"怎么用C++实现简易万年历",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"怎么用C++实现简易万年历"吧!代码如下:/**文件名称:万年历
千家信息网最后更新 2024年10月01日怎么用C++实现简易万年历
本篇内容主要讲解"怎么用C++实现简易万年历",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"怎么用C++实现简易万年历"吧!
代码如下:
/**文件名称:万年历.cpp*作 者:chenghan*完成日期:2019/1/10*版 本 号:1.0*问题描述:制作一个简单的万年历 */ #include#include using namespace std;//判断一年是否为闰年,是返回true 否返回falsebool isleapyear(int year); //兔子图案 void Rabbit(); //封装时间类 私有数据成员包括年月日 class Date{ private: int year, month, day; //私有数据成员 public: Date(){} //无参的构造函数 Date(int year, int month, int day); //有参的构造函数 void Disp_Date(); //显示星期数 void set(); //用户输入时间 int week(); //判断星期的函数 void show(); //显示日历的函数 };//主函数 int main(){ Date t; //创建一个Date类对象 string N="yes"; Rabbit(); while(N=="yes"){ t.set(); //调用设置时间函数 t.Disp_Date(); //显示星期 t.show(); //展示日历画面 cout<<"\n是否继续查询,是(yes)否(no)\n"; cin>>N; } return 0;}//判断一年是否为闰年,是返回true 否返回falsebool isleapyear(int year){ if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) return true; else return false;}//兔子图案void Rabbit() { cout< year = year; this->month = month; this->day = day;}//显示星期数void Date::Disp_Date(){ cout << year << "年" << month << "月" << day << "日 星期" ; switch(this->week()){ case 0: cout<<"日\n"; break; case 1: cout<<"一\n"; break; case 2: cout<<"二\n"; break; case 3: cout<<"三\n"; break; case 4: cout<<"四\n"; break; case 5: cout<<"五\n"; break; case 6: cout<<"六\n"; break; } } //用户设置时间void Date::set(){ cout<<"请输入您所想要查找的年、月、日:"; cin>>year>>month>>day;}//判断星期的函数 int Date::week(){ int C,y,d,M; if(this->month==1||this->month==2){ C = (this->year-1)/100; y = (this->year-1)0; M = this->month+12; d = this->day; } else{ C = this->year/100; //C世纪数减一 y = this->year0; //y年份后两位 d = this->day; //d是日 M = this->month; } int W = C/4 - 2*C + y + y/4 + 13 * (M+1) / 5 + d - 1; //判断星期的蔡勒公式 if (W < 0) /* 如果w是负数,则计算余数方式不同 */ { W = 7 - (-W) % 7; return W; //返回值1~6对应星期一到六 0对应七 } else return W%7;}//显示日历的函数 void Date::show(){ Date temp; temp.year = this->year; temp.month = this->month; temp.day = 1; int count = temp.week(); cout<<"---------------------------------------------------"< year<<"年"< month<<"月"<<"---------------------\n"; cout<<"日 一 二 三 四 五 六\n"; for(int i=0;i year)){ for(int j=1;j<30;j++){ if(j<10)cout<<" "< 到此,相信大家对"怎么用C++实现简易万年历"有了更深的了解,不妨来实际操作一番吧!这里是网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
函数
星期
万年历
时间
简易
C++
兔子
内容
图案
成员
数据
日历
用户
闰年
学习
私有
实用
更深
粗制滥造
世纪
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
关于互联网科技的书
ctc网络安全核查
江大数据库系统原理
最新的神经网络技术
吉首大学图书馆数据库怎样使用
游戏云服务器搭建
时序型数据库mongodb
张家口网络技术哪家强
中国服务器cpu市场规模
acsse数据库
查找标准的专业数据库网站
宁夏华为服务器报价
数据库实用工具中文最新版
数据库数据项意思
大兴区通用网络技术哪里好
企业的网络安全制度
湖南计算机专业网络技术学校
软件开发公司用什么财务软件
徐州常见的软件开发
中国自主网络技术
数据库的数据类型的划分
中国银行软件开发中心签约后
阿里云内网服务器联通
专业性网络技术推广口碑推荐
软件开发项目 会计处理
网络 数据库同步软件下载
网络安全培训的收获
国际网络安全峰会郑州
数据同步该先改缓存还是数据库
收银服务器ip怎么看