标签:des style blog http color io os ar java
1 5 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5
30#include<stdio.h> int a[100][100]; int max(int x,int y) { return x>y?x:y; } int main() { int T,i,j,n; scanf("%d",&T); while(T--) { scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) scanf("%d",&a[i][j]); } for(i=n-1;i>0;i--)//本题关键, 倒着求。 { for(j=1;j<=i;j++) a[i][j]=a[i][j]+max(a[i+1][j],a[i+1][j+1]); } printf("%d\n",a[1][1]); } return 0; }
标签:des style blog http color io os ar java
原文地址:http://blog.csdn.net/hdd871532887/article/details/40251441