The Time Machine-difference calculated by the time machine (within 24 hours)

Source: Internet
Author: User

The Time Machine-Time Machine calculation difference value (within 24 hours): enter hours, minutes, 1 stands for am, 0 stands for PM.

// The Time Machine-Time Machine calculation difference value (within 24 hours) # include <iostream> int computedifference (INT starthours, int startminutes, bool startisam, int endhours, int endminutes, bool endisam); int main () {using namespace STD; int starthours, startminutes, endhours, endminutes; bool startisam, endisam; int total_minutes; cout <"Please inout the start time (starthours, startminutes, startisam (1: am; 0: PM): \ n"; CIN> starthours> Star Tminutes> startisam; cout <"Please inout the end time (endhours, endminutes, endisam (1: am; 0: PM): \ n "; cin> endhours> endminutes> endisam; total_minutes = computedifference (starthours, startminutes, startisam, endhours, endminutes, endisam ); cout <"The difference value of the two time is" <total_minutes <"minutes! "<Endl; return 0;} int computedifference (INT starthours, int startminutes, bool startisam, int endhours, int endminutes, bool endisam) {using namespace STD; int total_minutes; if (true = startisam & false = endisam) {If (startminutes <= endminutes) total_minutes = (endhours-starthours) * 60 + (endminutes-startminutes ); else total_minutes = (endhours-1-starthours) * 60 + (endminutes + 60-startminutes);} else if (true = startisam & True = endisam) {If (starthours <endhours) {If (startminutes <= endminutes) total_minutes = (endhours-starthours) * 60 + (endminutes-startminutes ); else total_minutes = (endhours-1-starthours) * 60 + (endminutes + 60-startminutes);} else if (starthours> endhours) {If (startminutes> = endminutes) total_minutes = 24*60-(starthours-endhours) * 60 + (startminutes-endminutes); else total_minutes = 24*60-(starthours-1-endhours) * 60 + (startminutes + 60-endminutes);} else if (starthours = endhours) {If (startminutes <= endminutes) total_minutes = (endhours-starthours) * 60 + (endminutes-startminutes); else total_minutes = 24*60-(startminutes-endminutes);} else if (false = startisam & amp; false = endisam) {If (starthours <endhours) {If (startminutes <= endminutes) total_minutes = (endhours-starthours) * 60 + (endminutes-startminutes ); else total_minutes = (endhours-1-starthours) * 60 + (endminutes + 60-startminutes);} else if (starthours> endhours) {If (startminutes> = endminutes) total_minutes = 24*60-(starthours-endhours) * 60-(startminutes-endminutes); else total_minutes = 24*60-(starthours-1-endhours) * 60-(startminutes + 60-endminutes);} else if (starthours = endhours) {If (startminutes <= endminutes) total_minutes = (endhours-starthours) * 60 + (endminutes-startminutes); else total_minutes = 24*60-(startminutes-endminutes);} else if (false = startisam & True = endisam) {If (startminutes> = endminutes) total_minutes = 24*60-(starthours-endhours) * 60-(startminutes-endminutes ); else total_minutes = 24*60-(starthours-1-endhours) * 60-(startminutes + 60-endminutes);} return total_minutes ;}

Result:

Please inout the start time (startHours,startMinutes,startIsAM(1:AM;0:PM)):11 59 1Please inout the end time (endHours,endMinutes,endIsAM(1:AM;0:PM)):12 01 0The difference value of the two time is 2 minutes!Please inout the start time (startHours,startMinutes,startIsAM(1:AM;0:PM)):11 59 1Please inout the end time (endHours,endMinutes,endIsAM(1:AM;0:PM)):11 58 1The difference value of the two time is 1439 minutes!


The Time Machine-difference calculated by the time machine (within 24 hours)

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.