#include<iostream>
using namespace std;
int suma(int a[100], int s, int d)
{ if(s==d) return a[s];
else return suma(a,s,(s+d)/2)+suma(a,(s+d)/2+1,d);
}
int main()
{
int a[100],n,i;
cin>>n;
for(i=1;i<=n;i++) cin>>a[i];
cout<<suma(a,1,n);
system("pause");
return 0;
}
|