您的位置:首页 > 其它

一次格子取数的问题

2014-03-06 10:29 162 查看
#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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: