题解 | #小乐乐定闹钟#
小乐乐定闹钟
https://www.nowcoder.com/practice/0f7e422e12be4a7f9958ca2a82abc775
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String now = sc.next(); int sleep = sc.nextInt(); String[] strArr = now.split(":"); int nowHour = Integer.parseInt(strArr[0]); int nowMin = Integer.parseInt(strArr[1]); int sleepHour = (nowMin+sleep)/60; int endMin = (nowMin+sleep)%60; int endHour = (nowHour+sleepHour)%24; System.out.printf("%02d:%02d",endHour,endMin); } }