- 1
What is missing in my code?
2 odpowiedzi
+ 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;
}
+ 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