Advertisement
Spocoman

Exam Schedule

Oct 8th, 2024
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.66 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var hours, minutes int
  7.     fmt.Scanln(&hours)
  8.     fmt.Scanln(&minutes)
  9.  
  10.     var dayPart string
  11.     fmt.Scanln(&dayPart)
  12.    
  13.     var hoursAdded, minutesAdded int
  14.     fmt.Scanln(&hoursAdded)
  15.     fmt.Scanln(&minutesAdded)
  16.    
  17.     result := (hours + hoursAdded) * 60 + minutes + minutesAdded
  18.     totalHours := result / 60 % 24
  19.     totalMinutes := result % 60
  20.  
  21.     if totalHours >= 12 {
  22.         totalHours %= 12
  23.         if dayPart == "AM" {
  24.             dayPart = "PM"
  25.         } else {
  26.             dayPart = "AM"
  27.         }
  28.     }
  29.        
  30.     fmt.Printf("%02d:%02d:%s\n", totalHours, totalMinutes, dayPart)
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement