View Code of Problem 65

#include <stdio.h>
int main(){
  int t;
  scanf("%d",&t);
  int a[100][100];
  int i,j,r,m,p,q;
  for(i=0;i<t;i++){
    scanf("%d",&r);
    for(j=0;j<r;j++){
		for(m=0;m<=j;m++){
        scanf("%d",&a[j][m]);
		}
	}
    for(p=r-2;p>=0;p--){
        for(q=0;q<=p;q++){
           if(a[p+1][q]>a[p+1][q+1])
               a[p][q]+=a[p+1][q];
           else
               a[p][q]+=a[p+1][q+1];
                               
                       }
                         }
   printf("%d\n",a[0][0]);
      
    
                         
       
                         
  }
  
  
  
  
  return 0;
}

Double click to view unformatted code.


Back to problem 65