dwg1984
外卖仔
外卖仔
  • 注册日期2006-03-18
  • 发帖数74
  • QQ
  • 铜币322枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2326回复:0

[求助]怎么做?

楼主#
更多 发布于:2006-12-29 19:21
<P ><FONT face="Times New Roman">1.        </FONT>说出算法输出的结果</P>
<P > <FONT face="Times New Roman">void main( )<p></p></FONT></P>
<P ><FONT face="Times New Roman">{<p></p></FONT></P>
<P ><FONT face="Times New Roman">Stack S;<p></p></FONT></P>
<P ><FONT face="Times New Roman">Char x,y;<p></p></FONT></P>
<P ><FONT face="Times New Roman">InitStack(S);<p></p></FONT></P>
<P ><FONT face="Times New Roman">X=’a’;y=’b’;<p></p></FONT></P>
<P ><FONT face="Times New Roman">Push(S,x); Push(S,’c’);  Push(S,y);<p></p></FONT></P>
<P ><FONT face="Times New Roman">Pop(S,x); Push(S,’e’); Push(S,x);<p></p></FONT></P>
<P ><FONT face="Times New Roman">Pop(S,x); Push(S,’q’);<p></p></FONT></P>
<P ><FONT face="Times New Roman">while(!StackEmpty(S)){ Pop(S,y);printf(“%c  ”,y); };<p></p></FONT></P>
<P ><FONT face="Times New Roman">printf(“%c\n”,x);<p></p></FONT></P>
<P ><FONT face="Times New Roman">}</FONT></P>
<P ><FONT face="Times New Roman"></FONT> </P><FONT face="Times New Roman"><p>
<P >1.    说出下列算法的功能。<B > </B></P>
<P >int depth(BTreeNode * root)      <p></p></P>
<P >{<p></p></P>
<P >int d,  p;                    <p></p></P>
<P >p=0;<p></p></P>
<P >if(root==NULL)  return(p);       <p></p></P>
<P >else{ <p></p></P>
<P >d=depth(root->left);<p></p></P>
<P >if(d>p) p=d;               <p></p></P>
<P >d=depth(root->right);<p></p></P>
<P >if(d>p)p=d;<p></p></P>
<P >}<p></p></P>
<P >p=p+1;<p></p></P>
<P >return(p);<p></p></P>
<P >}<p></p></P>
<P ></p></FONT> </P>
喜欢0 评分0
如果有一天,当我真的离开你, 当你的心真的在痛,眼泪快要流下来的时候, 那就赶快抬起头,看看这片曾经属于我们的天空, 天依旧是那么的广阔,云依旧是那么的潇洒, 那就不应该哭,因为我的离去,并没有带走你的世界!
游客

返回顶部