File tree Expand file tree Collapse file tree 1 file changed +16
-17
lines changed
HackerRank/Algorithms/Easy Expand file tree Collapse file tree 1 file changed +16
-17
lines changed Original file line number Diff line number Diff line change 2
2
3
3
using namespace std ;
4
4
5
-
6
5
int main () {
7
- string s;
8
- string h ;
9
- int hr ;
10
- cin>>s ;
11
- hr = ((s[ 0 ]- ' 0 ' )* 10 )+(s[ 1 ]- ' 0 ' );
12
- if (s[ 8 ]== ' P ' &&s[ 9 ]== ' M ' && hr == 12 ) cout<< to_string (hr) ;
13
- else if (s[8 ]== ' P' && s[9 ]== ' M' ) cout<< to_string (hr+ 12 );
14
- else if (s[ 8 ]== ' A ' &&s[ 9 ]== ' M ' &&hr== 12 ) cout<< " 00 " ;
15
-
16
- else cout<< s[ 0 ]<<s[ 1 ] ;
17
-
18
-
19
- for (int i =2 ;i< 8 ; i++)
20
- cout<< s[i];
21
- cout<< endl;
22
- return 0 ;
6
+ string s, h ;
7
+ int hr ;
8
+ cin >> s ;
9
+ hr = ((s[ 0 ] - ' 0 ' ) * 10 ) + (s[ 1 ] - ' 0 ' ) ;
10
+ if (s[ 8 ] == ' P ' && s[ 9 ] == ' M ' && hr == 12 )
11
+ cout << hr ;
12
+ else if (s[8 ] == ' P' && s[9 ] == ' M' )
13
+ cout << hr + 12 ;
14
+ else if (s[ 8 ] == ' A ' && s[ 9 ] == ' M ' && hr == 12 )
15
+ cout << 00 ;
16
+ else cout << s[ 0 ] << s[ 1 ];
17
+
18
+ for (int i = 2 ; i < 8 ; i++)
19
+ cout << s[i];
20
+ cout << endl;
21
+ return 0 ;
23
22
}
You can’t perform that action at this time.
0 commit comments