一段程序的问题,#includeusing std::cout;using std::cin;using std::endl;#includeusing std::setw;#define StackSize 100typedef struct stack{int size[StackSize];int top;}STACK;void initialStack(STACK*);int isEmptyStack(STACK*);int isFullStack(STACK
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/24 15:48:54
一段程序的问题,#includeusing std::cout;using std::cin;using std::endl;#includeusing std::setw;#define StackSize 100typedef struct stack{int size[StackSize];int top;}STACK;void initialStack(STACK*);int isEmptyStack(STACK*);int isFullStack(STACK
一段程序的问题,
#include
using std::cout;
using std::cin;
using std::endl;
#include
using std::setw;
#define StackSize 100
typedef struct stack
{
int size[StackSize];
int top;
}STACK;
void initialStack(STACK*);
int isEmptyStack(STACK*);
int isFullStack(STACK*);
void pushStack(STACK*,int x);
void popStack(STACK*);
int getTopElement(STACK*);
void initialStack(STACK * stack)
{
stack->top = -1;
}
int isEmptyStack(STACK *stack)
{
if(stack->top == -1)
return 1;
else
return 0;
}
int isFullStack(STACK *stack)
{
if(stack->top==StackSize-1)
return 1;
else
return 0;
}
void pushStack(STACK* stack,int x)
{
int flag = 1;
if(flag==isFullStack())
size[++stack->top] = x;
}
void popStack(STACK* stack)
{
int flag=1;
if(flag==isEmptyStack())
cout
一段程序的问题,#includeusing std::cout;using std::cin;using std::endl;#includeusing std::setw;#define StackSize 100typedef struct stack{int size[StackSize];int top;}STACK;void initialStack(STACK*);int isEmptyStack(STACK*);int isFullStack(STACK
#include
using std::cout;
using std::cin;
using std::endl;
#include
using std::setw;
#define StackSize 100
typedef struct stack
{
int size[StackSize];
int top;
}STACK;
void initialStack(STACK*);
int isEmptyStack(STACK*);
int isFullStack(STACK*);
void pushStack(STACK*,int x);
void popStack(STACK*);
int getTopElement(STACK*);
void initialStack(STACK * stack)
{
stack->top = -1;
}
int isEmptyStack(STACK *stack)
{
if(stack->top == -1)
return 1;
else
return 0;
}
int isFullStack(STACK *stack)
{
if(stack->top==StackSize-1)
return 1;
else
return 0;
}
void pushStack(STACK* stack,int x)
{
int flag = 1;
if(flag!=isFullStack(stack)) //stack 要弄进去 应该是不等于
{
stack->size[++stack->top] = x; //stack 要弄进去
}
}
void popStack(STACK* stack)
{
int flag=1;
if(flag!=isEmptyStack(stack)) //stack 要弄进去 应该是不等于
cout