You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
410 B
Go
39 lines
410 B
Go
package math
|
|
|
|
func Abs(n int) int {
|
|
if n >= 0 {
|
|
return n
|
|
}
|
|
return -n
|
|
}
|
|
|
|
func Max(a, b int, more ...int) int {
|
|
var v int
|
|
if a > b {
|
|
v = a
|
|
} else {
|
|
v = b
|
|
}
|
|
for _, next := range more {
|
|
if next > v {
|
|
v = next
|
|
}
|
|
}
|
|
return v
|
|
}
|
|
|
|
func Min(a, b int, more ...int) int {
|
|
var v int
|
|
if a < b {
|
|
v = a
|
|
} else {
|
|
v = b
|
|
}
|
|
for _, next := range more {
|
|
if next < v {
|
|
v = next
|
|
}
|
|
}
|
|
return v
|
|
}
|