fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main{
  4. public static void main(String[] args){
  5. Scanner sc = new Scanner(System.in);
  6. int rt = sc.nextInt();
  7. while(rt>0){
  8. String rs = sc.next();
  9. String[] s = rs.split(":");
  10. int h = Integer.parseInt(s[0]);
  11. int m = Integer.parseInt(s[1]);
  12. if(h >= 12){
  13. if(h > 12)
  14. h -= 12;
  15. System.out.printf("%02d:%02d PM\n", h, m);
  16. } else {
  17. if(h == 0)
  18. h = 12;
  19. System.out.printf("%02d:%02d AM\n", h, m);
  20. }
  21.  
  22. rt--;
  23. }
  24. }
  25. }
Success #stdin #stdout 0.14s 54628KB
stdin
11
09:41
18:06
12:14
00:59
00:00
14:34
01:01
19:07
11:59
12:00
21:37
stdout
09:41 AM
06:06 PM
12:14 PM
12:59 AM
12:00 AM
02:34 PM
01:01 AM
07:07 PM
11:59 AM
12:00 PM
09:37 PM