递归与迭代
最后发布时间:2020-05-08 11:58:08
浏览量:
减而治之(Decrease and conquer)
计算任意n个整数之和
#include <stdio.h>
int sum(int A[],int n){
return n<1? 0: sum(A,n-1)+A[n-1];
}
int main(){
int A[] = {1,2,3};
int B = sum(A,3);
printf("%d",B);
}