資源簡介
題目要求:
掌握最基本的自頂向下分析方法,即遞歸下降子程序方法,理解其特點和適用范圍(回溯,左遞歸等現象),鍛煉遞歸調用程序的構造方法。
代碼片段和文件信息
#include
#include
using?namespace?std;
string?str;
int?index=0;
bool?flag;
void?E();????????????????//E->TX;
void?X();????????????????//X->+TX?|?e
void?T();????????????????//T->FY
void?Y();????????????????//Y->*FY?|?e
void?F();????????????????//F->(E)?|?i
int?main()?{??????????????/*遞歸下降*/
????while(1)?{
????????flag=true;
????????cout<<“請輸入要測試的字符串:?(輸入#號退出)“< ????????cin>>str;
????????if(str[0]==‘#‘)
????????????return?0;
????????E();
????if(flag==true)
????????cout< ????else
????????cout< ????????index=0;
評論
共有 條評論