C++问题E:\Cpp1.cpp(95) : error C2601: 'push' : local function definitions are illegal

来源:百度知道 编辑:UC知道 时间:2024/05/17 07:16:03
#include"stdio.h"
#include"stdlib.h"
#define MAXSIZE 20
typedef int ElemType;
typedef struct BNode
{ElemType data;
struct BNode *lch,*rch;
}BNode;
typedef struct
{BNode *a[MAXSIZE];
int top;
}sqstack;
BNode *t,*p;int s2[MAXSIZE];
BNode *creat_bt1();
void inorder2(BNode *t);
void preorder(BNode *p);
void push(sqstack *s,BNode *x);
BNode *pop(sqstack *s);

int k,e,i,j,z;
void main()
{do
{printf("\n\n");
printf("\n\n 0.建立二叉树");
printf("\n\n 1.中序非递归遍历二叉树");
printf("\n\n 2.结束程序运行");
printf("\n===============================");
printf("\n 请输入您的选择(0,1,2)");
scanf("%d",&k);
switch(k)
{case 0:{printf("\n s输入(00)结束: ");
t=creat_bt1();
preorder(t);
}break;

#include"stdio.h"
#include"stdlib.h"

#define MAXSIZE 20

typedef int ElemType;

typedef struct BNode
{
ElemType data;
struct BNode *lch,*rch;
}BNode;

typedef struct
{
BNode *a[MAXSIZE];
int top;
}sqstack;

BNode *t,*p;

int s2[MAXSIZE];
BNode *creat_bt1();
void inorder2(BNode *t);
void preorder(BNode *p);
void push(sqstack *s, BNode *x);
BNode *pop(sqstack *s);

int k,e,i,j,z;

void push(sqstack *s,BNode *x)
{
if(s->top==MAXSIZE)
printf("\n stack overflow!");
else
{
s->top++;
s2[s->top]=1;
s->a[s->top]=x;
}
}

BNode *pop(sqstack *s)
{
BNode *x;
if(s->top==0)
{
printf("\n stack underflow!");
return(NULL);
}
else
{
x=s->a[s->top]