Code -Zeit -Komplexitätsrechner online
int func(int n,int m){
if (n==2)
return n-m;
else
return m*func(n-2,m-1)+1;
}
Mohammad Amin Berangi
int func(int n,int m){
if (n==2)
return n-m;
else
return m*func(n-2,m-1)+1;
}
int sum (int v[], int j)
{
return v[ j ] ;
}
main ( )
{
int N, ans = 0;
cin >> N;
int v [N] = {0};
for(int i = 0 ; i < N ; i++)
ans += sum(v, i);
}
int totalSum = 0;
int sumFromLeft = 0;
int sumFromRight = 0;
int array[] = {1,2,5,7,8};
for(int i=0; i<5; i++){
if(i==0){
totalSum += array[i];
sumFromLeft = totalSum - totalSum;
for(int j=i+1; j<5; j++){
sumFromRight += array[j];
}
}else{
sumFromRight = 0;
totalSum +=array[i];
sumFromLeft = totalSum - array[i];
for(int j=i+1; j<5; j++){
sumFromRight += array[j];
}
}
if(sumFromLeft == sumFromRight){
cout<<"Element "<<array[i]<<" has sum from left= "
<<sumFromLeft <<"and sum from right= "<<sumFromRight<<endl;
}
}
int sum (int v[], int j)
{
return v[ j ] ;
}
main ( )
{
int N, ans = 0;
cin >> N;
int v [N] = {0};
for(int i = 0 ; i < N ; i++)
ans += sum(v, i);
}