int sum5ToNRecursively(int n)(这个是要算从5到n的和,n大于5)
{
// if n is invalid, return 0
if (n < 5)
return 0;
if (n = 5)
return 5;
// check for the base case
// if it is the base case, return the base case value
else
{
return n+sum5ToNRecursively(n-1);
}
// if it is not the base case,
// call recursively
// modify the return value from the recursive call to be our answer
// return the answer
}
int countMoreThanSevensRecursively(int *array, int size)
这个是要算array中大于7的数 请问怎么用递归函数写这两个程序?感谢
谢谢!请问能帮我看下第一个function有没有什么问题吗~~~~~
追答if (n = 5)
这是赋值
应该if (n == 5)