Item three-???? Increase the input time by 1 hours, 1 minutes, and 1 seconds.

Source: Internet
Author: User

/* *copyright (c) 2014, Yantai University School of computer *all rights reserved. * File name: Test.cpp * Yang Hanning * Completion Date: March 18, 2015 * Version number: v1.0 * Problem Description: Increase the original time by one hour, one minute, and one second. * Input Description: Enter hours: minutes: seconds.    * Program output: The time after the change */#include <iostream>using namespace Std;class time{public:void set_time ();    void Show_time ();              void add_a_sec (int n);           Adds 1 seconds to void Add_a_minute (int n);            Added 1 minutes void add_an_hour (int n);    Added 1 hours private:bool is_time (int, int, int);    This member function is set to private and is appropriate, please taste int hour;    int minute; int sec;};    void Time::set_time () {char c1,c2;    cout<< "Please enter the time (format Hh:mm:ss)";        while (1) {cin>>hour>>c1>>minute>>c2>>sec; if (c1!= ': ' | |        c2!= ': ') cout<< "format is not correct, please re-enter" <<endl;        else if (!is_time (hour,minute,sec)) cout<< "Time is illegal, please re-enter" <<endl;    else break;                 }}void Time::show_time () {if (hour >24) hour=hour-24; Avoid early 25 26 hour situation cout<


Item three-???? Increase the input time by 1 hours, 1 minutes, and 1 seconds.

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.