mirror of
https://github.com/ViolentAyang/DataStructureC.git
synced 2026-02-03 02:13:14 +08:00
Create 栈的初始化.c
This commit is contained in:
27
栈/栈的初始化.c
Normal file
27
栈/栈的初始化.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#define MaxSize 10
|
||||
|
||||
typedef struct{
|
||||
int data[MaxSize]; //静态数组存放栈中元素
|
||||
int top; //栈顶指针
|
||||
}SqStack;
|
||||
|
||||
//初始化栈
|
||||
void InitStack(SqStack *S){
|
||||
S->top = -1;
|
||||
}
|
||||
//判断栈空
|
||||
bool StackEmpty(SqStack s){
|
||||
if(S.top==-1){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
int main(){
|
||||
SqStack S;
|
||||
InitStack(&S);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user