求大神解答,在线等 急

asks you to write a recursive method to determine whether an array of integers is in ascending order. Please consider the following recursive definition:

  • An empty array or a one-element array is in ascending order.
  • An array with two or more numbers is in ascending order if its first element is less or equal to the second, and the array starting from the second element is in ascending order.

For example, the array {2, 2, 4, 19) is in ascending order, while {7, 9, 6, 11} is not.

  1. Based on the recursive definition, please complete the method below to determine using recursion whether the given array is in ascending order starting from index startPos up to the end.

public bool IsAscending(int array, int startPos)

2.

How should one call the above method to determine whether a given integer array is entirely in ascending order?

int array肯定是不行的。

给你个代码,自己体会。

        public static bool IsAscending(int[] array, int startPos = 0)
        {
            return ((array.Length - startPos) <= 1) || ((array[startPos] <= array[startPos + 1]) && IsAscending(array, startPos + 1));
        }

 

叫你写个递归函数去判断一个数列是否是递增的。意思就是这样的。你这个什么代码也没有,什么都没有。没有人知道你具体遇到了什么问题

整个题目就是这样子,只给了public bool IsAscending(int array, int startPos),所以我不是很明白要怎么接下去