int num = 0;
void fun(int n,int** arr,int row,int start,int index,int count,int k)
{
count++; //用来表示当前第几步
if (count > k)
return;
for (int i=0; i<row; i++)
{
if (i == index)
continue;
if (arr[i][0] == start)
{
if (arr[i][1] == n-1 && count == k)
{
num++;
break;
}
else if (arr[i][1] == n-1 && count == k-1)//在倒数二步的时候判断下如果新的连接值已经等于 n-1(最大值) 那最后一步肯定不成功
continue;
fun(n,arr,row,arr[i][1],i,count,k);
}
}
}
int numWays(int n, int** relation, int relationSize, int* relationColSize, int k){
num = 0;
fun(n, relation, relationSize, 0, -1, 0, k);
return num;
}