Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize a simple perpetual calendar with C++

Shulou Source: shulou.com Published: 2022-06-03 14:06:05 09月23日 Update

This article mainly explains "how to use C++ to achieve a simple perpetual calendar", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "how to use C++ to achieve a simple perpetual calendar"!

The code is as follows:

/ * * File name: perpetual Calendar .cpp * author: chenghan* completion date: 2019 Universe 10 * version number: 1.0 * problem description: making a simple perpetual calendar * / # include#include using namespace std;// to determine whether a year is a leap year, whether to return true or not to return falsebool isleapyear (int year); / / Rabbit pattern void Rabbit () / / Encapsulation time private data members include year, month and day class Date {private: int year, month, day; / / Private data member public: Date () {} / / No parameter constructor Date (int year, int month, int day); / / parameter constructor void Disp_Date (); / / display week void set (); / / user input time int week () / / function to determine the day of the week void show (); / function to display the calendar}; / / main function int main () {Date t; / / create a Date class object string N = "yes"; Rabbit (); while (naming = "yes") {t.set (); / / call the set time function t.Disp_Date (); / / display the day of the week (); / / display the calendar screen coutN } return 0;} / / to determine whether a year is a leap year, and whether to return true returns falsebool isleapyear (int year) {if ((year% 4 = = 0 & & year% 100! = 0) | | year% 400 = = 0) return true; else return false;} / / Rabbit pattern void Rabbit () {cout

Tags: Functions weeks perpetual calendars time simple calendar rabbits content patterns members data calendars users leap years learning private practical deeper shoddy century Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Apple macOS Microsoft MySQL