Maximum of Integer Sequences

Let's get the maximum amount of value from this sequence of numbers:

60, 50, 95,80, 70

1. Algorithmic ideas:

Compare arrays[i] with arrays[i + 1], if arrays[i] > arrays[i + 1] are exchanged. So continue until the last number, arrays[length - 1] is the maximum


func max(arrays []int, length int) int {
    for i := 0; i < length - 1; i++ {
        if arrays[i] > arrays[i + 1]  {
            temp := arrays[i]
            arrays[i] = arrays[i + 1]
            arrays[i + 1] = temp
        }

    }
    maxValue := arrays[length - 1]
    return maxValue
}

func main() {
    var scores = []int{60, 50, 95, 80, 70}
    var length = len(scores)
    var maxValue = max(scores, length)
    fmt.Printf("Max Value = %d\n", maxValue)
    }