c implementation----------------------------path in pyramid
we come botom to up ---------------------
eg:store like it(_we go ether right or down))
1
1 2
1 2 3
=>
step 2)  6
step 1)  3 5
            1 2 3

--->
#include<stdio.h>
int a[100][100];

void solve(int m)
{
int t1,t2,j1;

if(m==-1)
printf("%d\n",a[0][0]);
else{
for(j1=0;j1<=m;j1++)
{
t1=a[m][j1]+a[m+1][j1];
t2=a[m][j1]+a[m+1][j1+1];
a[m][j1]=t1>t2?t1:t2;}
solve(m-1);
}}
int main()
{
int i,j,re,n;




sudhir
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
{

scanf("%d",&a[i][j]);
}}
solve(n-2);

return 0;
}



SUDHIR
MNNIT ALLAHABAD--

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to