首页 > 玄幻魔法 > 那么修女小姐要怎么办呢 > 假条,今天要写编译原理,来不及更新啦

假条,今天要写编译原理,来不及更新啦(1/2)

目录
好书推荐: 我家李白不可能是女装大佬 帝世无双 洪荒之太一神话 衍生空间大反派 罪恶之生存游戏 带着崩玉诸天 星墟战记 明星批发商 史上最强大妖 倾世锁魂

//:

//

#include“stdafx.h“

#include<iostreaess“;

}

else{

cout<“error:fail!“;

flag=0;

b

}

}

cout<

if(ty())b

if(n>0)

{p->child=(0).i

node*temp=p->child->i

for(inti=1;i<n;i++)

{

temp->bro=(i).i

temp=temp->bro;

}

}

n=0;

}

}

/********************************************************************/

/*语义分析*/

voidsemanti_ana(my_stack<node>&stack,node*s)//主体部分,对后序遍历得到的后缀树进行栈操作,得出最后结果,放在后序遍历循环体中

{

stringout=““;

boolhasundefine=f

if(s->id>=0&&s->id<19)

{

if(s->id==10)

{

cout<left<setw(40)<““;

cout<“returntop[0].val“;

cout<

cout<“结果:“;

if(hasundefine)

cout<s;

else

cout<setw(40)<w();

}

elseif(s->id==0)

{

if(s->index->hasval)

().index->val=sin(().index->val);

else

{

out+=“sin(“+().index->text+“)“;

().index->text=out;

().index->hasval=f

}

cout<setw(40)<w();

cout<“top[0].text=“<().index->

cout<“,top[0].val=sin(top[0].val)“;

}

elseif(s->id==1)

{

if(s->index->hasval)

().index->val=cos(().index->val);

else

{

out=“cos(“+().index->text+“)“;

().index->text=out;

().index->hasval=f

}

cout<setw(40)<w();

cout<“top[0].text=“<().index->

cout<“,top[0].val=cos(top[0].val)“;

}

elseif(s->id==2)

{

if(s->index->hasval)

().index->val=tan(().index->val);

else

{

out=“tan(“+().index->text+“)“;

().index->text=out;

().index->hasval=f

}

cout<setw(40)<w();

cout<“top[0].text=“<().index->

cout<“,top[0].val=tg(top[0].val)“;

}

elseif(s->id==3)

{

if(s->index->hasval)

().index->val=tan(1.57-().index->val);

else

{

out=“cot(“+().index->text+“)“;

().index->text=out;

().index->hasval=f

}

cout<setw(40)<w();

cout<“top[0].text=“<().index->

cout<“,top[0].val=ctg(top[0].val)“;

}

elseif(s->id==4)

{

if(s->index->hasval)

().index->val=log(().index->val);

else

{

out=“log(“+().index->text+“)“;

().index->text=out;

().index->hasval=f

}

cout<setw(40)<w();

cout<“top[0].text=“<().index->

cout<“,top[0].val=log(top[0].val)“;

}

elseif(s->id==5)

{

if(s->index->hasval)

().index->val=log10(().index->val);

else

{

out=“lg(“+().index->text+“)“;

().index->text=out;

().index->hasval=f

}

cout<setw(40)<w();

cout<“top[0].text=“<().index->

cout<“,top[0].val=lg(top[0].val)“;

}

elseif(s->id==6)

{

if(s->index->hasval)

().index->val=log(().index->val);

else

{

out=“ln(“+().index->text+“)“;

().index->text=out;

().index->hasval=f

}

cout<setw(40)<w();

cout<“top[0].text=“<().index->

cout<“,top[0].val=ln(top[0].val)“;

}

elseif(s->id==11)

{

if((0).index->hasval&&(1).index->hasval)

{

doubletemp=().index->val;

();

().index->val+=

().index->text=to_string(().index->val);

}

else{

out=“(“+(1).index->text+“+“+(0).index->text+“)“;

(1).index->text=out;

(1).index->hasval=f

();

}

cout<setw(40)<w();

cout<“top[1].val+=top[0].val,pop()“;

}

elseif(s->id==12)

{

if((0).index->hasval&&(1).index->hasval)

{

doubletemp=().index->val;

();

().index->val-=

().index->text=to_string(().index->val);

}

else{

out=“(“+(1).index->text+“-“+(0).index->text+“)“;

(1).index->text=out;

(1).index->hasval=f

();

}

cout<setw(40)<w();

cout<“top[1].val-=top[0].val,pop()“;

}

elseif(s->id==13)

{

if((0).index->hasval&&(1).index->hasval)

{

doubletemp=().index->val;

();

().index->val*=

().index->text=to_string(().index->val);

}

else{

out=(1).index->text+“*“+(0).index->

(1).index->text=out;

(1).index->hasval=f

();

}

本章未完,点击下一页继续阅读。

目录
新书推荐: 开局迎娶苏家神女,奖励重瞳体! 洪荒:三清也得乖乖叫我一声二叔 万古长生,葬尽诸天仙神 我将要一统大陆 武侠:杀敌爆修为,我功力滔天! 高武:从肝二郎神天赋开始变强(已改名:高武:从武道生到宇宙天尊) 摆烂就无敌,出生秒仙帝 长生万古,苟到大帝再出关! 巫师:我的称号面板 我在气运长河钓出个万古神朝
返回顶部