题解 | 小乐乐定闹钟
#include <stdio.h> int main() { long int k; int h,m,tem_m; int sh,sm,res; scanf("%d:%d %ld",&h,&m,&k); tem_m = h*60+m+k;//总分钟数 res = tem_m/60;//完整小时 sm = tem_m%60;//分钟 if(res>=24){ sh = res%24; }else{ sh = res; } /* if(sh<10){ if(sm<10){ printf("0%d:0%d",sh,sm); }else{ printf("0%d:%d",sh,sm); } }else{ if(sm<10){ printf("%d:0%d",sh,sm); }else{ printf("%d:%d",sh,sm); } } */ printf("%02d:%02d\n",sh,sm); return 0; }