In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about how to use Clock to simulate the operation of the alarm clock in C++. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Define a clock class Clock, design the member function SetAlarm (int hour,int minute,int second) to set the ringing time; use the run () member function to simulate the clock operation, and prompt the bell when running to the ringing time.
The current time is set to 02:08:58, the alarm time is set to 03:40:05, and the clock runtime displays the time of each second.
The code is as follows:
# includeusing namespace std;class Clock {private: int Hour,Minute,Second,hour,minute,second;public: Clock (int Hour=0,int Minute=0,int Second=0) {/ / constructor this- > Hour=Hour,this- > Minute=Minute,this- > Second=Second;} ~ Clock () {} / / destructor void SetClock () {/ / set current time (manually entered) coutMinute > > Second } void SetAlarm (int hour,int minute,int second) {/ / set the alarm time (main function) this- > hour=hour,this- > minute=minute,this- > second=second;} void run () {for (; (Hourly hours)) | | (Second++ Second++) {carry Second=0; Minute++ of if (Second==59) {/ / seconds If (Minute==59) {/ / carry Minute=0; Hour++; if (Hour==24) {/ / cyclic Hour=0;} cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.