标题:问一个问题
取消只看楼主
shizhusz110
Rank: 1
等 级:新手上路
帖 子:307
专家分:0
注 册:2006-12-21
 问题点数:0 回复次数:3 
问一个问题

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

搜索更多相关主题的帖子: private include public return 
2007-01-07 09:54
shizhusz110
Rank: 1
等 级:新手上路
帖 子:307
专家分:0
注 册:2006-12-21
得分:0 

怎么没人理我啊?

2007-01-07 13:31
shizhusz110
Rank: 1
等 级:新手上路
帖 子:307
专家分:0
注 册:2006-12-21
得分:0 
xiexixe
2007-01-10 09:08
shizhusz110
Rank: 1
等 级:新手上路
帖 子:307
专家分:0
注 册:2006-12-21
得分:0 

谢谢斑竹教诲

2007-01-10 09:33



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-114698-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.117275 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved