Advertisement
Spocoman

01. Pipes In Pool

Sep 16th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.24 KB | None | 0 0
  1. package main
  2. import "fmt"
  3.  
  4. func main() {
  5.     var volume, pipe1, pipe2 int
  6.     fmt.Scanln(&volume)
  7.     fmt.Scanln(&pipe1)
  8.     fmt.Scanln(&pipe2)
  9.    
  10.     var hours float64
  11.     fmt.Scanln(&hours)
  12.    
  13.     var poolV = float64(pipe1 + pipe2) * hours
  14.     var poolP = poolV / float64(volume)
  15.  
  16.     if (float64(volume) >= poolV) {
  17.         fmt.Printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.",
  18.                     poolP * 100, float64(pipe1) / poolV * hours * 100, float64(pipe2) / poolV * hours * 100)
  19.     } else {
  20.             fmt.Printf("For %f hours the pool overflows with %.2f liters.", hours, poolV - float64(volume))
  21.     }
  22. }
  23.  
  24. ИЛИ:
  25.  
  26. package main
  27. import "fmt"
  28.  
  29. func main() {
  30.     var volume, pipe1, pipe2, hours float64
  31.     fmt.Scanln(&volume)
  32.     fmt.Scanln(&pipe1)
  33.     fmt.Scanln(&pipe2)
  34.     fmt.Scanln(&hours)
  35.    
  36.     var poolV = (pipe1 + pipe2) * hours
  37.     var poolP = poolV / volume
  38.  
  39.     if (volume >= poolV) {
  40.         fmt.Printf("The pool is %.2f%% full. Pipe 1: %.2f%%. Pipe 2: %.2f%%.",
  41.                     poolP * 100, pipe1 / poolV * hours * 100, pipe2 / poolV * hours * 100)
  42.     } else {
  43.             fmt.Printf("For %f hours the pool overflows with %.2f liters.", hours, poolV - volume)
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement