Exercise one: Alarm clock procedure

Source: Internet
Author: User

Description: Implement a simple alarm clock

Logic:

Seconds i++ when judging greater than or equal to 60

Minutes ++j When the judgment is greater than or equal to 60

Clock ++k to zero when judged to be greater than or equal to 24

Control output format

Points:

SETW: Setting the output width

Setfill: Setting padding content

Setprecision: Set the number of significant digits

Setiosflags: Set left or right

1#include <iostream>2#include <iomanip>3#include <windows.h>4 using namespacestd;5 6 intMain ()7 {8     intI=0, j=0, k=0;9      while(1)Ten     { One          for(i=0;i< -;++i) A         { -i=i% A; -Cout<<setfill ('0') &LT;&LT;SETW (2) <<k<<':'&LT;&LT;SETW (2) <<j<<':'&LT;&LT;SETW (2) <<i<<Endl; theSleep ( +); -         } -++J; -j=j% -; +         if(j==0) -         { +++K; Ak=k% -; at         } -     } -     return 0; -}

Exercise one: Alarm clock procedure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.