大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
只有简单的状态显示
#include "iostream"
using namespace std;
void AT(char monkeyplace, char boxplace)
{
cout << "AT(monkey," << monkeyplace << ")" << endl;
cout << "AT(box," << boxplace << ")" << endl;
}
void STATE(int on, int HB)
{
if (on == 0)
cout << "!ONBOX" << endl;
else
cout << "ONBOX" << endl;
if (HB == 0)
cout << "!HB" << endl;
else
cout << "HB" << endl;
}
char GOTO(char ST, char LT)
{
if (ST != LT)
return LT;
else
return ST;
}
void ACT(char monkey, char box, char banana, int on, int HB)
{
if (monkey != banana)
{
cout << "=============GOTO(" << monkey << "," << box << ")===============>" << endl;
monkey = GOTO(monkey, box);
AT(monkey, box);
STATE(on, HB);
cout << endl;
}//猴子移动至箱子处
if (monkey != banana)
{
cout << "=============PUSH(" << monkey << "," << banana << ")===============>" << endl;
monkey = GOTO(monkey, banana);
AT(monkey, banana);
STATE(on, HB);
cout << endl;
}//猴子搬运箱子至香蕉处
if (monkey == banana && on == 0)
{
cout << "=============CLIMBBOX===============>" << endl;
AT(monkey, banana);
on++;
STATE(on, HB);
cout << endl;
}//猴子爬上箱子
if (monkey == banana && on == 1 && HB == 0)
{
cout << "=============GRASP===============>" << endl;
AT(monkey, banana);
HB++;
STATE(on, HB);
cout << endl;
}//猴子摘香蕉
}
int main()
{
char monkey, box, banana;
int on = 0, HB = 0;
cout << "猴子的位置:";
cin >> monkey;
cout << "箱子的位置:";
cin >> box;
cout << "香蕉的位置:";
cin >> banana;
cout << endl;
cout << "=============开始===============>" << endl;
AT(monkey, box);
STATE(on, HB);
cout << endl;//初始状态
ACT(monkey, box, banana, on, HB);
system("pause");//按任意键退出
return 0;
}
第一次用这个博客编辑器 先搞个简单的试试怎么用
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/189283.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...