You are viewing a single comment's thread. Return to all comments →
Same number of lines, less variables, no string comparisons. One atoi though.
atoi
int main() {
char time[11] = {0}; scanf("%s", time); int n_hour = atoi(time); char plus12 = n_hour >= 12; n_hour += time[8] == 'P' ? (plus12 ? 0 : 12) : (plus12 ? -12 : 0); printf("%02d:%.*s:%.*s", n_hour, 2, time + 3, 2, time + 6); return 0;
}
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 →
Same number of lines, less variables, no string comparisons. One
atoi
though.int main() {
}