-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathConvertTime.cpp
More file actions
48 lines (45 loc) · 924 Bytes
/
Copy pathConvertTime.cpp
File metadata and controls
48 lines (45 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int h,m,s;
char a1,a2,temp,temp1;
cin >> h >> a1 >> m >> a2 >> s >> temp >> temp1;
if(temp=='A')
{
if(h==12)
h=00;
if(h<10 )
cout << "0"<< h << a1;
else
cout << h << a1;
if(m<10 )
cout << "0" << m << a2;
else
cout << m << a2 ;
if(s<10 )
cout << "0" <<s;
else
cout << s;
}
else if(temp=='P')
{
if(h<12)
h += 12;
if(h<10 )
cout << "0"<< h << a1;
else
cout << h << a1;
if(m<10 )
cout << "0" << m << a2;
else
cout << m << a2 ;
if(s<10 )
cout << "0" <<s;
else
cout << s;
}
return 0;
}