Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++: 1. Given four digits, find the maximum valid time that can be displayed on a digital clock (in 24-hour format) using those digits.

In C++:

1. Given four digits, find the maximum valid time that can be displayed on a digital clock (in 24-hour format) using those digits.

For example, given digits 1,8,3,2 the maximum valid time is "23:18". Note that "28:31" is not a valid time.

Write a function:

string MaxTime(int A, int B, int C, int D);

that, given four integers A,B,C,D, returns the maximum valid time in string format "HH:MM" or "NOT POSSIBLE" if it is not possible to display a valid time.

Examples: given 1,8,3,2, the function MaxTime shoud return "23:18".

Given 2,4,0,0 the funtion should return "20:40".

Given 3,0,7,0 the function should return "07:30"

Given 9,1,9,7 the function should return "NOT POSSIBLE". Since there is no possible valid time.

Assume that: A,B,C,D are integers with in the range [0..9]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions

Question

1. What is meant by Latitudes? 2. What is cartography ?

Answered: 1 week ago