You are viewing a single comment's thread. Return to all comments →
Stream approach:
int main(){ string time; int hours,seconds,minutes; string merid; char delim; stringstream ss; cin >> time; ss << time; ss >> hours >> delim >> minutes >> delim >> seconds >> merid; if((merid=="PM"&&hours!=12)||(merid=="AM"&&hours==12)) hours=(hours+12)%24; printf("%02d:%02d:%02d", hours, minutes, seconds); return 0; }
Critique welcome!
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 →
Stream approach:
Critique welcome!