Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var hours, minutes int
- fmt.Scanln(&hours)
- fmt.Scanln(&minutes)
- var dayPart string
- fmt.Scanln(&dayPart)
- var hoursAdded, minutesAdded int
- fmt.Scanln(&hoursAdded)
- fmt.Scanln(&minutesAdded)
- result := (hours + hoursAdded) * 60 + minutes + minutesAdded
- totalHours := result / 60 % 24
- totalMinutes := result % 60
- if totalHours >= 12 {
- totalHours %= 12
- if dayPart == "AM" {
- dayPart = "PM"
- } else {
- dayPart = "AM"
- }
- }
- fmt.Printf("%02d:%02d:%s\n", totalHours, totalMinutes, dayPart)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement