Advertisement
Spocoman

06. Number sequence

Sep 20th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.48 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "math"
  6. )
  7.  
  8. func main() {
  9.     var n, number int
  10.     fmt.Scanln(&n)
  11.    
  12.     var minNumber = math.MaxInt64
  13.     var maxNumber = math.MinInt64
  14.  
  15.     for i := 0; i < n; i++ {
  16.         fmt.Scanln(&number)
  17.         if (number < minNumber) {
  18.             minNumber = number
  19.         }
  20.         if (number > maxNumber) {
  21.             maxNumber = number
  22.         }
  23.     }
  24.    
  25.     fmt.Printf("Max number: %d\nMin number: %d", maxNumber, minNumber)
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement