max number
This commit is contained in:
parent
62fdc454d7
commit
96b985bbc8
2 changed files with 20 additions and 1 deletions
19
arrays/demo3.go
Normal file
19
arrays/demo3.go
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package arrays
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func Demo3() {
|
||||||
|
numbers := [5]int{20, 30, 50, 10, 2}
|
||||||
|
fmt.Println(numbers)
|
||||||
|
|
||||||
|
max_number := numbers[0]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for i := 0; i < len(numbers); i++ {
|
||||||
|
if numbers[i] > max_number {
|
||||||
|
max_number = numbers[i]
|
||||||
|
}
|
||||||
|
fmt.Println("max number : ", max_number)
|
||||||
|
}
|
||||||
|
}
|
2
main.go
2
main.go
|
@ -13,5 +13,5 @@ func main() {
|
||||||
fmt.Print()
|
fmt.Print()
|
||||||
conditionals.Demo3()
|
conditionals.Demo3()
|
||||||
loops.Demo5()
|
loops.Demo5()
|
||||||
arrays.Demo2()
|
arrays.Demo3()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue