https://code.sololearn.com/cLWKVJjfszsB/?ref=app
4/13/2021 6:39:08 PM
TeaserCode2 Answers
New AnswerThe hour display should have a length of 2. Here's what I'd managed from my limited knowledge of C++: #include <iostream> using namespace std; int main() { int a, b; char c; cin >> a; cin >> c; cin >> b; cin >> c; if (c == 'P') { a = (a + 12) % 24; } if (a < 10) cout << "0"; cout << a << ":"; if (b < 10) cout << "0"; cout << b; return 0; }
TeaserCode Your code not working for some cases.. For single digit hour in AM , you should append '0' to show in double digit. 1:00 AM => 01:00 12:00 AM => 00:00 12:00 PM => 12:00
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message