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.

31 lines
417 B

1 year ago
#include<iostream>
using namespace std;
int SumArray(int a[], int n, int len)
{
if (n == 0) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
return 0;
}
else //<2F>ݹ<EFBFBD><DDB9><EFBFBD><EFBFBD><EFBFBD>
{
return a[len - n] + SumArray(a, n - 1, len);
}
}
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>";
cin >> n;
cout<<"<EFBFBD><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;
}