作者TonyQ (骨头)
站内java
标题Re: [问题] 谁可以帮我看一下传回值哪出问题了 -STACK
时间Tue Apr 11 15:03:30 2006
※ 引述《chiunyao (..)》之铭言:
: 这事实做一个STACK 新手多多见谅~~
: 我刚开始设定 TOP=-1
: 可是只要呼叫到 push(s,num2,top);
: PUSH函数里面有top++
: 可是婐是过了~~怎麽样丢回来 top的值都还是在-1 根本没有++
: 请问是哪出错了呢~~
: 谢谢罗~
基本上 把变数丢到METHOD里面去跑 回传以後
资料不见得会跟着改变
: push(s,num2,top);
改成top= push(.....); 应该就可以解决了
: pop(s,top);
同上 也要把top做对应的--
另外 可以试着不要把这些计算过程写在main
试试写成object吧 就像java.util.Stack那样 , 会简洁许多:)
--
Local
--
String temp="relax"; | Life just like programing
while(buringlife) String.forgot(temp); | to be right or wrong
while(sleeping) brain.setMemoryOut(); | need not to say
stack.push(life.running); | the complier will
stack.push(scouting.buck()); | answer your life
stack.push(bowling.pratice()); | Bone
everything
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.138.240.57
※ 编辑: TonyQ 来自: 140.138.240.57 (04/11 15:04)