助けてください! iは関数にパラメータとして渡されます 私の構造は、次のとおりstructが再帰関数の引数として渡された場合、どのようにstructのメンバ変数を初期化するのですか?
は私のクエリにコンテキストでコードをsumarised下記
struct mine_index
{
int row, col;
};
struct miner
{
bool up, down, right, left;
};
can_solve(mine_index start, mine_index end, miner the_miner)
{
can_solve(start(row+1,col), end, miner the_miner);
return ;
}
が
bool can_solve(mine_index start, mine_index end, miner the_miner)
{
bool solution[size-1][size-1]
for (int i=0; i<size; i++)
{
for (int j=0; j<size; j++)
{
solution[i][j]=0;
}
}
if(start.row==size-1 && start.col==size-1)//base case
{
solution[start.row][start.row]=1
return true;
{
if(start.row>=0 && start.row<size-1 && start.col>=0 && start.col<size-1) //
{
solution[start.row][start.col]=1;
}
if(can_solve(start(row+1,col), end, miner the_miner))
{
return true;
}
if(can_solve(start(row,col+1), end, miner the_miner))
{
return true;
}
if(can_solve(start(row-1,col), end, miner the_miner))
{
return true;
}
if(can_solve(start(start.row,start.col-1), end, miner the_miner))
{
return true;
}
}
は再帰関数の全体のコードでありますこの宣言は有効ではない場合、この宣言を宣言する別の方法があります。私は再帰関数を使用しています。機能全体を以下に示します。私は今ロジックに取り組む必要がありますが、私の構文が正しいかどうかを知りたいだけですか?
コンパイルは実行されますか? –