0

The question is

Let's consider a triangle of numbers in which a number appears in the first line, two numbers appear in the second line, three in the third line, etc. Develop a program which will compute the largest of the sums of numbers that appear on the paths starting from the top towards the base, so that

* on each path the next number is located on the row below, more precisely either directly below or below and one place to the right;

* the number of rows is strictly positive, but less than 100

* all numbers are positive integers between O and 99.

My program for this program is not working

can you please help.

```
#include<iostream>
using namespace std;
void sum(int array[][101],int n);
int main()
{
int array[101][101];
int i,j,n;
cin>>n;
for(i=0;i<n;i++)
for(j=0;j<=n;j++)
{
if(j>i)
array[i][j]=0;
else
cin>>array[i][j];
}
int l=n-1;
while(l--)
{
sum(array,l-2);
}
for(i=0;i<n;i++)
cout<<array[0][i]<<" ";
}
void sum(int array[][101],int n)
{
for(int i=0;i<n;i++)
{
if((array[n][i]+array[n-1][i])>(array[n][i+1]+array[n-1][i]))
array[n-1][i]+=array[n][i];
else
array[n-1][i]+=array[n][i+1];
}
}
```