asks you to write a recursive method to determine whether an array of integers is in ascending order. Please consider the following recursive definition:
For example, the array {2, 2, 4, 19) is in ascending order, while {7, 9, 6, 11} is not.
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),所以我不是很明白要怎么接下去