View Code of Problem 65

#include <stdio.h>
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n,i,j;
		int a[1000][100];
		scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			for(j=0;j<=i;j++)
			{
				scanf("%d",a[i][j]);
			}
		}
		for(i=n-1;i>0;i--)
		{
			for(j=0;j<i;j++)
			{
				if(a[i][j]>a[i][j+1]) a[i-1][j]+=a[i][j];
				else a[i-1][j]+=a[i][j+1];
			}	
		}
		printf("%d\n",a[0][0]);
        return 0;
}
/*
Main.c: In function 'main':
Main.c:15:5: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
     scanf("%d",a[i][j]);
     ^
Main.c:28:1: error: expected declaration or statement at end of input
 }
 ^
*/

Double click to view unformatted code.


Back to problem 65