注册 登录
编程论坛 C++教室

问一个问题

shizhusz110 发布于 2007-01-07 09:54, 458 次点击

#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++数据结构.万分谢谢!!!

5 回复
#2
shizhusz1102007-01-07 13:31

怎么没人理我啊?

#3
caiqiufu2007-01-09 22:09
也是没有学懂啊
看了几遍都没有看懂
对不起了!!!
#4
shizhusz1102007-01-10 09:08
xiexixe
#5
一二三四五2007-01-10 09:31
呵呵,刚学C++就从简单的地方开始做起吧,

基础学好了,这些东西慢慢就会了
#6
shizhusz1102007-01-10 09:33

谢谢斑竹教诲

1