本文實(shí)例為大家分享了C++實(shí)現(xiàn)簡易的萬年歷,供大家參考,具體內(nèi)容如下
代碼如下:
/**文件名稱:萬年歷.cpp*作  者:chenghan*完成日期:2019/1/10*版 本 號:1.0*問題描述:制作一個簡單的萬年歷 */ #include<iostream>#include <string>using namespace std;//判斷一年是否為閏年,是返回true 否返回falsebool isleapyear(int year); //兔子圖案 void Rabbit();  //封裝時間類 私有數(shù)據(jù)成員包括年月日 class Date{ private:  int year, month, day; //私有數(shù)據(jù)成員  public:  Date(){} //無參的構(gòu)造函數(shù)   Date(int year, int month, int day); //有參的構(gòu)造函數(shù)   void Disp_Date();  //顯示星期數(shù)   void set(); //用戶輸入時間   int week(); //判斷星期的函數(shù)  void show(); //顯示日歷的函數(shù) };//主函數(shù) int main(){  Date t; //創(chuàng)建一個Date類對象   string N="yes";  Rabbit();  while(N=="yes"){ t.set(); //調(diào)用設(shè)置時間函數(shù)  t.Disp_Date(); //顯示星期    t.show();  //展示日歷畫面    cout<<"/n是否繼續(xù)查詢,是(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<<endl;  cout<<"         ┏━┓ ┏━┓"<<endl;  cout<<"作者:chenghan  ★│┃ ┃│┃"<<endl;  cout<<"         ┃│┗灬┛│┃"<<endl;  cout<<"版本:1.0     ┃     ┃"<<endl;  cout<<"         ┃ ^   ^ ┃"<<endl;  cout<<"時間:2019/1/10   
主站蜘蛛池模板:
高淳县|
天祝|
威远县|
安图县|
浦县|
库尔勒市|
安泽县|
夏河县|
昭通市|
渝中区|
北海市|
宜兰市|
宜兴市|
平顺县|
永兴县|
崇州市|
长顺县|
水城县|
宜阳县|
临清市|
杭锦后旗|
花莲市|
丁青县|
永胜县|
高邮市|
海南省|
广灵县|
宁明县|
建水县|
梧州市|
宁乡县|
鸡泽县|
太谷县|
卓资县|
平潭县|
稻城县|
太湖县|
铜川市|
渭源县|
河东区|
徐州市|