私の switch ステートメントの目的は、ランダムに生成された 0 から 7 までの入力を入力して、7 つのタスクを実行することです。これは私のコードです:
switch(move)
{
case 0:
//up
movement = 1;
next = vf.plv(x,y,movement,cp,np);
//hit cell membrane
if(next == 0)
{
move = vf.mv(0);
}
else
{ cout<<j<<"\t"<<x<<"\t"<<y+1<<endl;
virus[j].setvpoint(x,y+1,j,movement);
break;
}
case 1:
//up-right
movement = 2;
next = vf.plv(x,y,movement,cp,np);
//hit cell membrane
if(next == 0)
{
move = vf.mv(1);
}
else
{
cout<<j<<"\t"<<x+1<<"\t"<<y+1<<endl;
virus[j].setvpoint(x+1,y+1,j,movement);
break;
}
case 2:
//right
movement = 3;
next = vf.plv(x,y,movement,cp,np);
//hit cell membrane
if(next == 0)
{
move = vf.mv(2);
}
else
{
cout<<j<<"\t"<<x+1<<"\t"<<y<<endl;
virus[j].setvpoint(x+1,y,j,movement);
break;
}
case 3:
//down-right
movement = 4;
next = vf.plv(x,y,movement,cp,np);
//hit cell membrane
if(next == 0)
{
move = vf.mv(3);
}
else
{
cout<<j<<"\t"<<x+1<<"\t"<<y-1<<endl;
virus[j].setvpoint(x+1,y-1,j,movement);
break;
}
case 4:
//down
movement = 5;
next = vf.plv(x,y,movement,cp,np);
//hit cell membrane
if(next == 0)
{
move = vf.mv(4);
}
else
{
cout<<j<<"\t"<<x<<"\t"<<y-1<<endl;
virus[j].setvpoint(x,y-1,j,movement);
break;
}
case 5:
//down-left
movement = 6;
next = vf.plv(x,y,movement,cp,np);
//hit cell membrane
if(next == 0)
{
move = vf.mv(5);
}
else
{
cout<<j<<"\t"<<x-1<<"\t"<<y-1<<endl;
virus[j].setvpoint(x-1,y-1,j,movement);
break;
}
case 6:
//left
movement = 7;
next = vf.plv(x,y,movement,cp,np);
//hit cell membrane
if(next == 0)
{
move = vf.mv(6);
}
else
{
cout<<j<<"\t"<<x-1<<"\t"<<y<<endl;
virus[j].setvpoint(x-1,y,j,movement);
break;
}
case 7:
//left-up
movement = 8;
next = vf.plv(x,y,movement,cp,np);
//hit cell membrane
if(next == 0)
{
move = vf.mv(7);
}
else
{
cout<<j<<"\t"<<x-1<<"\t"<<y+1<<endl;
virus[j].setvpoint(x-1,y+1,j,movement);
break;
}
default:
cout<<"Default"<<endl
}
next = vf.plv(x,y,movement,cp,np)は、x 座標と y 座標に応じて 0 または 1 を出力する関数です。x 座標と y 座標が距離の式に入力され、中心からの距離が決定されます。距離が 13 以上の場合、次は 0 になります。0 の場合、 move = vf.mv(7)関数は新しいこのスイッチ関数に戻される 0 から 7 までの数値
私が抱えている問題は、スイッチ関数が再帰的に新しい数値を 3 回生成し、距離が 13 未満になるまで続行するのではなく、デフォルトのステートメントに戻ることです。do while ループを実行しようとしましたが、まだ動作しませんでした。
この問題を解決するための次のステップは何ですか?
前もって感謝します!