Skip to content

Commit

Permalink
Merge pull request CodePanda66#31 from BruceDai003/patch-1
Browse files Browse the repository at this point in the history
Update DS_2_0_SqStack.cpp
  • Loading branch information
KimYangOfCat authored Dec 4, 2020
2 parents 704ee1e + ba18b5f commit 9bbd08f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions DataStructure/Src/DS_2_StackAndQueue/DS_2_0_SqStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ int GetTopOther1(SqStack S) {
void PrintStack(SqStack S) {
printf("从栈顶元素开始,栈如下:\n");
while (S.top >= 0) {//注意判空的条件
printf("S[%d]=%d\n", S.top, S.data[S.top--]);
printf("S[%d]=%d\n", S.top, S.data[S.top]);
S.top--;
}
printf("栈打印完毕\n");
}
Expand All @@ -129,7 +130,8 @@ void PrintStack(SqStack S) {
void PrintStack1(SqStack S) {
printf("从栈顶元素开始,栈如下:\n");
while (S.top > 0) {//注意判空的条件
printf("S1[%d]=%d\n", S.top - 1, S.data[--S.top]);//初始化方式1得先移动指针再获取元素
S.top--;
printf("S1[%d]=%d\n", S.top, S.data[S.top]);//初始化方式1得先移动指针再获取元素
}
printf("栈打印完毕\n");
}
Expand Down Expand Up @@ -214,4 +216,4 @@ int main() {
printf("Hello, SqStack!");
testStack();
return 0;
}
}

0 comments on commit 9bbd08f

Please sign in to comment.