猴子摘香蕉实验报告(含代码)(2)

2019-04-21 17:01

};

struct State States [150]; char* routesave[150];

/*function monkeygoto,it makes the monkey goto the other place*/ void monkeygoto(int b,int i) {

int a; a=b; if (a==-1) { }

else if(a==0) { }

else if(a==1) { }

routesave[i]=\States[i+1]=States[i]; States[i+1].monkey=-1;

routesave[i]=\States[i+1]=States[i]; States[i+1].monkey=0;

routesave[i]=\States[i+1]=States[i]; States[i+1].monkey=1;

else

{ }

/*end function monkeyygoto*/

/*function movebox,the monkey move the box to the other place*/ void movebox(int a,int i) {

int B; B=a; if(B==-1) { }

else if(B==0) { }

else if(B==1)

printf(\

}

routesave[i]=\States[i+1]=States[i]; States[i+1].monkey=-1; States[i+1].box=-1;

routesave[i] = \States[i+1]=States[i]; States[i+1].monkey=0; States[i+1].box=0;

}

{ } else { }

printf(\

routesave[i] = \States[i+1]=States[i]; States[i+1].monkey=1; States[i+1].box=1;

/*end function movebox*/

/*function climbonto,the monkey climb onto the box*/ void climbonto(int i) { }

routesave[i]=\States[i+1]=States[i]; States[i+1].monbox=1;

/*function climbdown,monkey climb down from the box*/ void climbdown(int i) {

routesave[i]=\States[i+1]=States[i];

}

States[i+1].monbox=-1;

/*function reach,if the monkey,box,and banana are at the same place,the monkey reach banana*/ void reach(int i) { }

routesave[i]=\

/*output the solution to the problem*/ void showSolution(int i) { int c;

printf (\ for(c=0; c

printf (\

}

printf(\}

/*perform next step*/ void nextStep(int i) {

int c;

int j; if(i>=150) {

printf(\ \\n\

return; }

for (c=0; c

{

if(States[c].monkey==States[i].monkey&&States[c].box==States[i].box&&States[c].banana==States[i].banana&&States[c].monbox==States[i].monbox) {

return;

} }

if(States[i].monbox==1&&States[i].monkey==0&&States[i].banana==0&&States[i].box==0) {

} j=i+1;

if(States[i].monkey==0) {

if(States[i].box==0) {

if(States[i].monbox==-1) {

showSolution(i);

printf(\

getchar();/*to save screen for user,press any key to continue*/ return;


猴子摘香蕉实验报告(含代码)(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:重庆市南开中学2017-2018学年高三9月月考英语试题 Word版含解析

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: