为了学校的一个项目,我正在做一个RPN计算器。这个计算器有一个抽象类堆栈,其中三个不同的堆栈实现派生自。其中之一是链表堆栈。对于这些堆栈,我必须显示堆栈上的值。为此,我使用了一个数组。对于我的arraystack和list栈来说,这很容易,但我不知道如何将链表转换为数组。做到这一点的最好方法是什么?
这是我在链表中使用的代码。
public class Node
{
public int data;
public Node next;
public Node(int i)
{
data = i;
next = null;
计算器代码:
@IBAction func Calc(sender: UIButton) {
var a = Int(curppm.text!)
var b = Int(tarppm.text!)
var c = Int(vol.text!)
}
我收到一个错误,显示:
initialization of variable (a,b,c) was never used.
这是我的第一个应用,有点卡住了。感谢您的帮助。