大神们快帮学妹看看这是哪里出错了
c++吧
全部回复
仅看楼主
level 1
rgy300 楼主
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<stack>//顺序栈定义及基本操作
using namespace std;
#define true 1;
#define false 0;
#define StackInitSize 100
typedef struct{
int *base;
int *top;
}SqStack;
void InitStack(SqStack &S){
}
int StackEmpty(SqStack S){
if(S.base==S.top)
{return true;}
else return false;
}
int Push(SqStack &S,int e){
if(S.top-S.base>=StackInitSize)
{
printf("栈满!栈发生上溢,程序运行终止!\n");
exit(0);
}
else{
*S.top++=e;
return 0;
} }
int Pop(SqStack &S, int &e){
if(S.base==S.top)
{
printf("栈为空!");
return 1;
}
S.top--;
e=*S.top;
return 0;
}
void main(){
int N;
int e;
SqStack s;
InitStack(s);
scanf("%d",&N);
while(N){
Push(s,N%8);
N=N/8;
}
while(!StackEmpty(s)){
Pop(s,e);
printf("%d",e);
}
}
我就是用栈换指针指的位置时有错误,但我不知道哪里错了
2015年11月07日 03点11分 1
1