问题重现
根据蓝桥杯题目的简化,从”从“开始走,构成:从我做起振兴中华
从我做起振
我做起振兴
做起振兴中
起振兴中华
已知数组,如下:
int arr[SIZE][SIZE]={
{0,1,2,3,4},
{1,2,3,4,5},
{2,3,4,5,6},
{3,4,5,6,7}
};
请试图去寻找一条轨迹(横走或者竖走,不允许按对角线走),轨迹为:01234567,求一共有多少种走法?
//解法一:递归实现
#include<stdio.h>
#define SIZE 5
int count=0;
void fun(int i,int j,int deep){
if(deep==8){
count++;
return;
}
if(i<SIZE-2){
//行
fun(i+1,j,deep+1);
}
if(j<SIZE-1){
//列
fun(i,j+1,deep+1);
}
}
void main(){
fun(0,0,1);
printf("%d\n",count);
}