# SUMTRAIN : Please point out if any test case is missing ...

#include <stdio.h>
#include<stdlib.h>
int n;
void input(int a[100][100])
{
int i,j,p;
scanf("%d",&n);
if(n <0)
{
exit(0);
}
else
{

``````	for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
scanf("%d",&p);
if(p>0 && p <100)
{
a[i][j]=p;
}
else
{
exit(0);
}
}

}
}
``````

}

/void display(int a[100][100])
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
}
/
int sumtriangle(int a[100][100])
{
int i,j,max,Result_max=0;
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{
if(i==0)
{
max=a[i][j];
Result_max=max;
}
else if(i!=0 && j==0)
{
a[i][j]=a[i][j]+a[i-1][j];
Result_max=a[i][j];

``````		}
else if(i!=0 &&j>0 && j<i)
{
max=a[i-1][j-1]+a[i][j];

if(max<(a[i-1][j]+a[i][j]))
{
max=a[i-1][j]+a[i][j];
}

a[i][j]=max;
if(max>Result_max)
{
Result_max=max;
}

}
else
{
a[i][j]=a[i][j]+a[i-1][j-1];
if((max=a[i][j])>Result_max)
{
Result_max=max;
}
}
}

}
return Result_max;
``````

}
int main(void) {

``````int a[100][100],times,result[1000],i=0,j;
scanf("%d",&times);
while(times--)
{

input(a);
result[i++]=sumtriangle(a);
//display(a);
}

for(j=0;j<i;j++)
{
printf("%d\n",result[j]);
}

return 0;
``````

}

This the code for SUMTRAIN which I have written but it is saying Wrong answer Please Help !!