13th Apr 2021, 6:39 PM
TeaserCode
3 Respostas
+ 1
The 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; }
13th Apr 2021, 7:00 PM
Calvin Thomas
Calvin Thomas - avatar
+ 1
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
13th Apr 2021, 8:53 PM
Jayakrishna 🇮🇳