输入:XXX XXX 小时 分钟
输出:
XXX:XXX ~ XXX: XXX
XXX:XXX ~ XXX: XXX
XXX:XXX ~ XXX: XXX
处理:间隔五分钟、区间45分钟
14:15 ~ 15:0
15:5 ~ 15:50
15:55 ~ 16:40
16:45 ~ 17:30
17:35 ~ 18:20
18:25 ~ 19:10
19:15 ~ 20:0
20:5 ~ 20:50
20:55 ~ 21:40
21:45 ~ 22:30
import java.util.Scanner;public class timetable {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int a = scanner.nextInt();int b = scanner.nextInt();while (a<22) {if(b+45>60){System.out.println(a+":"+ b+" ~ "+(a+1)+":"+ (b+45-60));b=b+50-60;a++;}else if(b+45==60){System.out.println(a+":"+ b+" ~ "+(a+1)+":00");b=b+50-60;a++;}else if(b-5==0){System.out.println(a+":"+ b+"0"+" ~ "+a+":"+ (b+45));b=b+50;}else{System.out.println(a+":"+ b+" ~ "+a+":"+ (b+45));b=b+50;}}}
}