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

假条,今天要写编译原理,来不及更新啦(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

();

}

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

目录
新书推荐: 蓝卡星空 瘤剑仙 人在高武,言出法随 巫师之上 遮天之无极大道尊 荒古圣体觉得我太极端! 一心退休的我却成了帝国上将 人形凶器,肉身成圣 万般特质加身,我终将成为不朽 我的天道版本太低,所以全是漏洞
返回顶部