集册 Java实例教程 带偏移索引的求和数组

带偏移索引的求和数组

欢马劈雪     最近更新时间:2020-01-02 10:19:05

566
带偏移索引的求和数组


//package com.nowjava;

/**
 from
* N o w  J a v a  .   c o m 
**/

public class Main {

    public static double sum(double[] input, int offset, int len) {

        double sum = 0;

        for (int i = offset; i < offset + len; i++) {

            sum += input[i];

        }

        return sum;

    }

}