mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hamza elkhatri
54c5214072
|
2 years ago | |
---|---|---|
.. | ||
README.md | 2 years ago |
README.md
count-negative
Instructions
Write a function that takes an array of integers and returns the number of negative numbers in the array.
- If the array is empty, the function should return
0
.
Expected function
func CountNegative(numbers []int) int {
// your code here
}
Usage
Here is a possible program to test your function:
package main
import "fmt"
func main(){
fmt.Println(CountNegative([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}))
fmt.Println(CountNegative([]int{-1, -2, -3, -4, -5, -6, -7, -8, -9, -10}))
fmt.Println(CountNegative([]int{}))
fmt.Println(CountNegative([]int{-1,2,0,-3}))
}
and the output should be:
$ go run .
0
10
0
2