| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 5194 人关注过本帖
标题:如何使用堆栈法???
只看楼主 加入收藏
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
 问题点数:0 回复次数:65 
如何使用堆栈法???
从键盘输入一个表达式(比如:6+3+5+9),只有加号的。
求结果。
好像是用堆栈方法做的。就是不知道该如何着手。
高手帮下忙啊。
搜索更多相关主题的帖子: 堆栈 键盘 加号 结果 
2005-04-02 14:07
leeteng
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2005-1-7
收藏
得分:0 
用的是逆波兰算法,先将表达式换算成波兰表达式---运算符后置。判断是数字还是运算副,数字则压栈 ,运算副就出栈 运算》
2005-04-02 15:42
leeteng
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2005-1-7
收藏
得分:0 
你学是C语言? 晕,我的是用C#实现的。 逆波兰---- 5+9 --> 5 9 +.。  (3+5)*5 ---> 3 5 + 5 * 以第二个为例子。 当遇到3 压栈,遇到5 压栈 遇到+(不是数字,你需要判断当前的是数字还是运算副),出栈---5 和3  将5 加上3   5+3 = 8 。将8压栈。接着又遇到第二个五--数字,压栈。接着遇到*  出栈----8 和 5  进行8*5 = 40  将40 压栈 碰到结束符号 将40出栈,则40就是运算结果,  你得将输入转换成逆波兰结构  再将表达市分割存入数组 依次从数组中取元素 判断是数字还是运算副,进行上面的运算后 你就得到答案了。 你得实现一个堆栈结构(自己实现)。
2005-04-02 15:55
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
C的题用C#解而已啦。谢谢咯

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-02 16:29
leeteng
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2005-1-7
收藏
得分:0 
哈哈 你在啊
2005-04-02 16:29
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
是啊。以后会天天在的。
找题目做啊。顺便学习咯

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-02 16:37
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
逆波兰是什么??
我刚学不久不知道诶。
逆波兰的主语句不会

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-02 16:39
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
帮自己顶一下。老大帮忙啊

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-04 10:53
leeteng
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2005-1-7
收藏
得分:0 
就是波兰的一个数学家发现 数学表达市中的括号是完全可以不用的--利用他的转换就能将括号去掉  ,就是运算副后置。
例如  1 + 2   转换成他的式子就是 1 2 +     1+2+3-4   转换过来就是 1 2 + 3 + 4 -   (1+5)*6  就是1 5 + 6 *   
2005-04-04 12:06
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
主语句说一下行吗。
不知道主语句还是想不出来.

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-04 12:15
快速回复:如何使用堆栈法???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016209 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved