请教高手,帮忙看看,这个程序哪里有错!编译时没错,运行时就有错了

来源:百度知道 编辑:UC知道 时间:2024/07/04 07:46:40
功能是表达式求值
#include<stdio.h>
#include<stdlib.h>
#include<iostream.h>
#include<math.h>
#include<string.h>
struct sqstack{
int data[100];
int top;
};
void init_stack(sqstack *s)
{s->top=-1;}
void push_stack(sqstack *s,char x)
{s->top++;
s->data[s->top]=x;}
void pop_stack(sqstack *s,int *x)
{*x=s->data[s->top];s->top--;}
int gettop(sqstack *s)
{return s->data[s->top];}
//------------------定义操作符-----------------

char op[8]={'(',')','+','-','*','/','^','%'};

//---------------判断是否是操作符-------------

int in(char c,char op1[])
{int i=0,j;
while(op1[i]=='/0')
{if(c==op1[i])
{j=1;}
else
j=0;
i++;}
return j;
}
//----------------栈外级别--------------------
int you1(char a)
{int i;
s

貌似你的题目和我们做过的一个类似,给你看下我当时做的吧,运行没问题,不过只能进行简单的整形运算
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"

/*栈节点类型*/
typedef struct node
{
char data;
struct node *next;
}snode,*slink;
typedef struct node_post
{
int data;
struct node_post *next;
}pnode,*plink;

/*全局变量定义*/
slink top=NULL;
plink ptop=NULL;

/*栈空检测,空时为1*/
int Emptystack()
{
if(top==NULL)return 1;
else return 0;
}

/*出栈,返回top中data*/
char Pop()
{
char e;
slink p;
if(top==NULL)return(-1);
else
{
p=top;
top=top->next;
e=p->data;
free(p);
return e;
}
}
int Pop_post()
{
int e;
plink p;
if(ptop==NULL)return(-1);
else
{
p=ptop;
ptop=ptop->next;
e=p->data;
free(p);