-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimeConversion.cpp
More file actions
52 lines (51 loc) · 791 Bytes
/
TimeConversion.cpp
File metadata and controls
52 lines (51 loc) · 791 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
49
50
51
52
#include <iostream>
using namespace std;
int main() {
char s[10];
for(int i=0;i<10;i++)
{
cin>>s[i];
}
int h1,h2,hh;
h1=s[0]-48;
h2=s[1]-48;
hh=(10*h1)+h2;
if(s[8]=='A'||s[8]=='a')
{
if(hh<12)
{
for(int i=0;i<8;i++)
{
cout<<s[i];
}
}
else if(hh==12)
{
cout<<0<<0;
for(int i=2;i<8;i++)
{
cout<<s[i];
}
}
}
if(s[8]=='P'||s[8]=='p')
{
if(hh<12)
{
int sum= 12+hh;
cout<<sum;
for(int i=2;i<8;i++)
{
cout<<s[i];
}
}
else if(hh==12)
{
cout<<1<<2;
for(int i=2;i<8;i++)
{
cout<<s[i];
}
}
}
}