callFunctions(4);
if (Камень уже есть в руках) Кинуть(3);
C++ (Qt)#include <QtCore/QCoreApplication>#include <QVector>#include <QDebug> QVector<void(*)()> vecOfFunc; void func0(){ qDebug() << "func0";} void func1(){ qDebug() << "func1";} void func2(){ qDebug() << "func2";} void func3(){ qDebug() << "func3";} void func4(){ qDebug() << "func4";} void startFrom(int i){ if (vecOfFunc.size() <= i) return; for (; i < vecOfFunc.size(); ++i) (*vecOfFunc.at(i))();} int main(int argc, char *argv[]){ vecOfFunc.append(func0); vecOfFunc.append(func1); vecOfFunc.append(func2); vecOfFunc.append(func3); vecOfFunc.append(func4); startFrom(2);}
C++ (Qt)while(!asleep()) sheep++;
#include <QCoreApplication>#include <QQueue>#include <QDebug>QQueue<void (*)()> queue;void checkQueue(){ if (queue.size() <= 0) return; queue.removeAt(0); if (queue.size() <= 0) return; (queue.at(0))();}void one(){ qDebug() << Q_FUNC_INFO; checkQueue();}void tow(){ qDebug() << Q_FUNC_INFO; checkQueue();}void tree(){ qDebug() << Q_FUNC_INFO; checkQueue();}int main(int argc, char *argv[]){ QCoreApplication a(argc,argv); queue.append(&one); queue.append(&tow); queue.append(&tree); (queue.at(0))(); queue.append(&tow); queue.append(&tree); (queue.at(0))(); queue.append(&tree); queue.append(&tow); queue.append(&one); (queue.at(0))(); return 0;}
C++ (Qt)void MyClass::Run( void ){ while (true) { switch (mState) { case state_Init: mState = DoInit() ? state_Prepare : state_Error; ... break; case state_Error: ... break; case state_Prepare: ... break; } }}