You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
385 B

1 year ago
#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 << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
cin >> n;
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
for (int i = 0; i < n; i++) {
cin >> a[i];
}
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>Ϊ<EFBFBD><EFBFBD>" ;
cout << SumArray(a, n, n);
return 0;
}