题解 | #小乐乐定闹钟#
小乐乐定闹钟
https://www.nowcoder.com/practice/0f7e422e12be4a7f9958ca2a82abc775
#include <stdio.h> int main() { int hour, minute, k; scanf("%d:%d %d", &hour, &minute, &k); int t1 = 0, t2 = 0,sum = 0; sum = hour*60+minute+k; //总时间,先累和再分算 t1 = sum / 60; if (t1 > 24) { t1 = t1 % 24; };//防止输入时间大于24小时 t2 = sum % 60; //分钟 printf("%02d:%02d", t1, t2); return 0; }