#ifndef STACK_H
#define STACK_H
const int MAX =100
class stack{
private:
DataType stack[MAX];
int top;
public:
stack(void);
int stackemty(void)const;
void push(const DataType& item);
DataType pop(void);
};
#endif
#include"iostream.h"
#include"stdlib.h"
#include"stack.h"
typedef int DataType;
stack::stack(void):top(-1)
{
}
int stack::stackempty()const
{return top=-1;}
void stack::push(const DataType& item)
{ if(top==MAX-1)
exit(1);
stack[top]=item;
top++;
}
DataType stack::pop(void)
{ DataType temp;
if(top==-1)
exit(1);
temp=stack[top];
top--;
}
return temp;
}
#include"iostream.h"
#include"stdlib.h"
#include"stack.h"
typedef int DataType;
int main()
{stack s;
int i,j;
cout<<"\n is 2,8,16:"<<endl;
cin>>i>>j;
while(i!=0){
s.push(i%j);
i=i/j;
}
while(!s.stackempty())
cout<<s.pop()<<endl;
return 0;
}
错误很多帮忙该下!我才在学c++,又没c++数据结构.万分谢谢!!!