Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在这段代码中,N 是下一个空白空间的索引,而不是堆栈中最后插入的 String 的索引。因此,当执行 a[--N] 时,这确实首先减少了 N,但它指向最后插入的项目“to”。
遇到第一个“-”时,栈如下:
a[0] = "to" a[1] = "be" a[2] = "or" a[3] = "not" a[4] = "to"
N 为 5。