#include <stdio.h> #include <stdlib.h> int geZiQuShu(int num[][4], int h, int l){ int up, left; if(h < 0 || l < 0) return 0; if(h == 0 && l == 0) return num[0][0]; up = geZiQuShu(num, h - 1, l); left = geZiQuShu(num, h, l - 1); if(up > left){ return up + num[h][l]; } else{ return left + num[h][l];; } } main(){ int num[4][4] = {20, 20, 20, 4, 5, 6, 20, 8, 9, 10, 20, 12, 13, 14, 20, 20}; int result; result = geZiQuShu(num, 3, 3); printf("%d \n", result); }
原文:http://www.cnblogs.com/yutoulck/p/3583951.html