mirror of https://github.com/01-edu/public.git
subject(Count-Negative):add readme
This commit is contained in:
parent
9fd8117c3b
commit
1d8cacc5c6
|
@ -0,0 +1,38 @@
|
|||
## 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
|
||||
```go
|
||||
func CountNegative(numbers []int) int {
|
||||
// your code here
|
||||
}
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
```go
|
||||
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:
|
||||
|
||||
```console
|
||||
$ go run .
|
||||
0
|
||||
10
|
||||
0
|
||||
2
|
||||
```
|
Loading…
Reference in New Issue