C语言80行左右的编程

来源:百度知道 编辑:UC知道 时间:2024/06/20 01:15:28
如题,不要太难
请不要为了加分而乱留言

题目自拟,只要是80行左右能运行就行

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
typedef struct SqStack
{
int *base;
int *top;
int stacksize;
}
SqStack;
void InitStack(SqStack *S)
{
S->base=(int*)malloc(STACK_INIT_SIZE*sizeof(int));
S->top=S->base;
S->stacksize=STACK_INIT_SIZE;
}
void Push(SqStack *S,int e)
{
if(S->top-S->base>=S->stacksize)
{
S->base=(int*)realloc(S->base,
(S->stacksize+STACKINCREMENT)*sizeof(int));
S->top=S->base+S->stacksize;
S->stacksize+=STACKINCREMENT;
}
*(S->top)=e;
S->top++;
}
int Pop(SqStack *S)
{
S->top --;
return *S->top;

}
int StackEmpty(SqStack *S)
{
if(S->top == S-