Skip to content

Instantly share code, notes, and snippets.

@jtprogru
Created May 13, 2022 15:13
Show Gist options
  • Save jtprogru/1d3cc245c5d7d16d4f27115c7d7c86f0 to your computer and use it in GitHub Desktop.
Save jtprogru/1d3cc245c5d7d16d4f27115c7d7c86f0 to your computer and use it in GitHub Desktop.
Найдите количество минимальных элементов в последовательности. Вводится натуральное число N, а затем N целых чисел последовательности. Выведите количество минимальных элементов последовательности.
package main
import (
"fmt"
"sort"
)
func main() {
var inputNumber int
var counter uint = 1
var min int
_, _ = fmt.Scan(&inputNumber)
inputArray := make([]int, inputNumber)
for i := 0; i < inputNumber; i++ {
_, _ = fmt.Scan(&inputArray[i])
}
sort.Ints(inputArray)
min = inputArray[0]
for i := 1; i < inputNumber; i++ {
if min == inputArray[i] {
counter += 1
}
}
fmt.Println(counter)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment