1 Star 0 Fork 0

iamohenry/turing-machine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
TFunctionAddOne.cpp 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
iamohenry 提交于 2024-10-10 10:05 . add function: add one.
#include "TFunctionAddOne.h"
TFunctionAddOne::TFunctionAddOne()
{
}
TFunctionAddOne::~TFunctionAddOne()
{
}
void TFunctionAddOne::run()
{
qDebug() << "func add one is starting...";
reset();
m_config = eConfig_AddOne_Begin;
do {
switch (m_config) {
case eConfig_AddOne_Begin: {
if (m_cells[m_index] == 0) {
m_cells[m_index] = '0';
sendUpdateSignal();
m_config = eConfig_AddOne_Increment;
}
}
break;
case eConfig_AddOne_Increment: {
if (0 == m_cells[m_index]) {
m_cells[m_index] = '1';
sendUpdateSignal();
m_config = eConfig_AddOne_rewind;
}
else if ('0' == m_cells[m_index]) {
m_cells[m_index] = '1';
sendUpdateSignal();
m_config = eConfig_AddOne_rewind;
}
else if ('1' == m_cells[m_index]) {
m_cells[m_index] = '0';
sendUpdateSignal();
m_index--;
sendUpdateSignal();
}
}
break;
case eConfig_AddOne_rewind: {
if (0 == m_cells[m_index]) {
m_index--;
sendUpdateSignal();
m_config = eConfig_AddOne_Increment;
}
else {
m_index++;
sendUpdateSignal();
}
}
break;
default:
break;
}
} while (m_index > 50);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/iamohenry/turing-machine.git
git@gitee.com:iamohenry/turing-machine.git
iamohenry
turing-machine
turing-machine
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385