recursively sum the integers in an array

前端 未结 9 1020
不思量自难忘°
不思量自难忘° 2020-12-06 03:01

I have a program that I\'m trying to make for class that returns the sum of all the integers in an array using recursion. Here is my program thus far:

public         


        
9条回答
  •  我在风中等你
    2020-12-06 03:59

    The issue is that a[n-1] is an int, whereas sumOfArray expects an array of int.

    Hint: you can simplify things by making sumOfArray take the array and the starting (or ending) index.

提交回复
热议问题