You are viewing a single comment's thread. Return to all comments →
#include <bits/stdc++.h> using namespace std; string timeConversion(string s) { string s1 = s.substr(8,2); string s2 = s.substr(0,2); string s3 = s.substr(2,6); if (s1=="AM"){ if (s2=="12"){ s2 = "00"; } } else if (s1=="PM"){ if (s2!="12"){ int a = stoi(s2) + 12; string s4 = to_string(a); s2 = s4; } } return s2+s3; } int main(){ string s; cin>>s; cout<<timeConversion(s); }
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →