标签:style blog color io ar 2014 div sp cti
/******************************************************************** * @file Main_practise.cpp * @date 2014-9-21 * @author Tiger * @brief 数字三角形 * @details 动态规划-递归计算 ********************************************************************/ #include <cstdio> #include <algorithm> const int NUM = 5; int Data[NUM][NUM] = { { 7 }, { 3, 8 }, { 8, 1, 0 }, { 2, 7, 4, 4 }, { 4, 5, 2, 6, 5 } }; int solve(int i, int j); int main(int argc, const char* argv[]) { printf("%d\n", solve(0, 0)); return 0; } int solve(int i, int j) { return Data[i][j] + (i == NUM-1 ? 0 : std::max(solve(i+1, j), solve(i+1, j+1))); }
标签:style blog color io ar 2014 div sp cti
原文地址:http://www.cnblogs.com/roronoa-zoro-zrh/p/3984491.html