Hey guys,

I have been trying to solve the sums in a triangle problem. Here’s the code:

```
#include<iostream>
using namespace std;
int a[10][10],j,k;
int func(int &n,int &r)
{
int large[10];
int sum=0;
for(j=1;j<r;j++)
for(k=0;k<=j;k++)
if(large[j] < a[j][k])
large[j] = a[j][k];
j=1;
while(j<r)
{
sum = sum + large[j];
++j;
}
return sum;
}
int main()
{
int s1[10];
int n,i=0,r;
cin>>n;
while(i<n)
{
cin>>r;
for(j=0;j<r;j++)
for(k=0;k<=j;k++)
cin>>a[j][k];
s1[i] = func(n,r);
++i;
}
for(i=0;i<n;i++)
cout<<s1[i]<<endl;
return 0;
}
```

I run this in the gcc compiler, it works(also in TurboC++), but on the codechef compiler it gives SIGSEGV error.

I know what it is but i don’t know what the mistake is in my code. Please, I need urgent help.

Thanks in advance