题解 | #小乐乐定闹钟#
小乐乐定闹钟
https://www.nowcoder.com/practice/0f7e422e12be4a7f9958ca2a82abc775
#include <stdio.h> //需要注意的是小时最大是24,超过24小时的要对24小时取模 int main() { int hour,minute; long long k; scanf("%d:%d %lld",&hour,&minute,&k); int new = k / 60; int newhour = hour + new; int new1 = k % 60; int newminute = new1 + minute; while(newminute >= 60) { newminute -= 60; newhour += 1; } newhour %= 24; printf("%02d:%02d\n",newhour,newminute); return 0; }