Advertisement
Spocoman

03. Harvest

Sep 16th, 2024 (edited)
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.22 KB | None | 0 0
  1. package main
  2. import (
  3.     "fmt"
  4.     "math"
  5. )
  6.  
  7. func main() {
  8.     var x int
  9.     fmt.Scanln(&x)
  10.    
  11.     var y float64
  12.     fmt.Scanln(&y)
  13.    
  14.     var z, workers int
  15.     fmt.Scanln(&z)
  16.     fmt.Scanln(&workers)
  17.  
  18.     var wine = 0.4 * float64(x) * y / 2.5;
  19.  
  20.     if (wine < float64(z)) {
  21.         fmt.Printf("It will be a tough winter! More %d liters wine needed.", (int)(float64(z) - wine))
  22.     } else {
  23.         fmt.Printf("Good harvest this year! Total wine: %d liters.\n", (int)(wine))
  24.         fmt.Printf("%d liters left -> %d liters per person.",
  25.                     (int)(math.Ceil(wine - float64(z))), (int)(math.Ceil((wine - float64(z)) / float64(workers))))
  26.     }
  27. }
  28.  
  29. ИЛИ:
  30.  
  31. package main
  32. import (
  33.     "fmt"
  34.     "math"
  35. )
  36.  
  37. func main() {
  38.     var x, y, z, workers float64
  39.     fmt.Scanln(&x)
  40.     fmt.Scanln(&y)
  41.     fmt.Scanln(&z)
  42.     fmt.Scanln(&workers)
  43.  
  44.     var wine = 0.4 * x * y / 2.5;
  45.  
  46.     if (wine < z) {
  47.         fmt.Printf("It will be a tough winter! More %d liters wine needed.", int(z - wine))
  48.     } else {
  49.         fmt.Printf("Good harvest this year! Total wine: %d liters.\n%d liters left -> %d liters per person.",
  50.                     int(wine), int(math.Ceil(wine - z)), int(math.Ceil((wine - z) / workers)))
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement