refactor: add/refactor method in include, simplified print code (#471)

This commit is contained in:
hpstory
2023-04-21 14:59:22 +08:00
committed by GitHub
parent 9c2e5e2831
commit 9eeefff447
24 changed files with 102 additions and 109 deletions

View File

@ -23,7 +23,7 @@ public class stack
stack.Push(5);
stack.Push(4);
// 请注意stack.ToArray() 得到的是倒序序列,即索引 0 为栈顶
Console.WriteLine("栈 stack = " + string.Join(",", stack.ToArray()));
Console.WriteLine("栈 stack = " + string.Join(",", stack));
/* 访问栈顶元素 */
int peek = stack.Peek();
@ -31,7 +31,7 @@ public class stack
/* 元素出栈 */
int pop = stack.Pop();
Console.WriteLine("出栈元素 pop = " + pop + ",出栈后 stack = " + string.Join(",", stack.ToArray()));
Console.WriteLine("出栈元素 pop = " + pop + ",出栈后 stack = " + string.Join(",", stack));
/* 获取栈的长度 */
int size = stack.Count();