Delete '递归求和.cpp'

main
p9zok7cfl 1 year ago
parent 5ee35b4eb3
commit f029c98d52

@ -1,26 +0,0 @@
#include <iostream>
using namespace std;
int SumArray(int a[], int n, int x) {
if (n == 0) {
return 0;
} else {
return a[x - n] + SumArray(a, n - 1, x);
}
}
int main() {
int a[50], n;
cout << "请输入数组中数的个数:";
cin >> n;
cout << "请向数组输入:";
for (int i = 0; i < n; i++) {
cin >> a[i];
}
cout << "数组的和为:" ;
cout << SumArray(a, n, n);
return 0;
}
Loading…
Cancel
Save