Advertisement
Spocoman

High Jump

Oct 10th, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.62 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var jumpTarget, jump, counter, fall int
  7.     fmt.Scanln(&jumpTarget)
  8.    
  9.     startJump := jumpTarget - 30
  10.  
  11.     for fall != 3 && startJump <= jumpTarget {
  12.         fmt.Scanln(&jump)
  13.         if jump > startJump {
  14.             startJump += 5
  15.             fall = 0
  16.         } else {
  17.             fall++
  18.         }
  19.         counter++
  20.     }
  21.  
  22.     if startJump <= jumpTarget {
  23.         fmt.Printf("Tihomir failed at %dcm after %d jumps.", startJump, counter)
  24.     } else {
  25.         fmt.Printf("Tihomir succeeded, he jumped over %dcm after %d jumps.", jumpTarget, counter)
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement