* 区别于自顶向下,另一种更简单的做法就是自底向上了.dp方程为 dp[m][n] = min(dp[m + 1][n], dp[m + 1][n + 1]) + triangle[m][n] 我们仍然可以使用一位数组滚动计算. * #define min(a,b) (ab?a:b) int minim mtotal(int** triangle, int trianglerowsize, int *trianglecolsizes) { int *dp = calloc(trianglecolsizes[trianglerowsize-1],sizeof(int)); int mintotal ; dp[0] = triangle[0][0]; for(int i = 0; i trianglecolsizes[trianglerowsize-1]; i) dp[i] = triangle[trianglerowsize-1][i]; for(int i = trianglerowsize-2; i =0; i--) for(int j = 0; j  trianglecolsizes[i]; j) dp[j] = min(dp[j],dp[j+1])+triangle[i][j]; ret rn dp[0];