214.数组的最大值

Max of Array

Description
Given an array with couple of float numbers. Return the max value of them.

Have you met this question in a real interview?  
Example
Given [1.0, 2.1, -3.3], return 2.1.

public class Solution {
    /**
     * @param A: An integer
     * @return: a float number
     */
    public float maxOfArray(float[] A) {
        // write your code here
        
        float max = A[0];
        for (int i=1; i<A.length; i++){
            if (max < A[i]){
                max = A[i];
            } 
        } 
        return max;
        
    }
}
描述
给一个浮点数数组,求数组中的最大值。

您在真实的面试中是否遇到过这个题?  
样例
给出数组 [1.0, 2.1, -3.3], 返回 2.1.
posted @ 2019-04-02 21:57  故人叹  阅读(124)  评论(0)    收藏  举报