Advertisement
Spocoman

Bus

Oct 3rd, 2024
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.53 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var passengers, stations, outputPassengers, inputPassengers int
  7.     fmt.Scanln(&passengers)
  8.     fmt.Scanln(&stations)
  9.  
  10.     for i := 1; i <= stations; i++ {
  11.         fmt.Scanln(&outputPassengers)
  12.         fmt.Scanln(&inputPassengers)
  13.         passengers += inputPassengers - outputPassengers
  14.  
  15.         if i % 2 == 1 {
  16.             passengers += 2
  17.         } else {
  18.             passengers -= 2
  19.         }
  20.     }
  21.  
  22.     fmt.Printf("The final number of passengers is : %d", passengers)
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement