题解 | #小乐乐定闹钟#
小乐乐定闹钟
https://www.nowcoder.com/practice/0f7e422e12be4a7f9958ca2a82abc775
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNext()){ String[] str=in.nextLine().split(" "); String[] s=str[0].split(":"); int hour=Integer.parseInt(s[0]); int minute=Integer.parseInt(s[1]); int k=Integer.parseInt(str[1]); int addhour=k/60; int addminute=k%60; hour+=addhour; minute+=addminute; if(minute>60){ minute=minute%60; hour++; } if(hour>23){ hour=hour%24; } if(hour<10&&minute<10){ System.out.println("0"+hour+":0"+minute); }else if(hour<10&&minute>10){ System.out.println("0"+hour+":"+minute); }else if(hour>10&&minute<10){ System.out.println(hour+":0"+minute); }else if(hour>10&&minute>10){ System.out.println(hour+":"+minute); } } in.close(); } }