#include<iostream>
using namespace std;
class stack
{
public:
stack();
bool empty() const;
bool full() const;
enum error_code{overflow,underflow,success};
error_code get_top(double &)const;
error_code push(const double);
error_code pop();
private:
int count;
double date[10000];
};
stack::stack()//初始化
{
count=0;
};
bool stack::empty()const//判空
{
if(count==0)
return 1;
return 0;
}
bool stack::full()const//判满
{
if(count==10000)
return 1;
return 0;
}
error_code stack::get_top(double &x)//出栈
{
if(empty())return underflow;
else
{
x=data[count-1];
return success;
}
}
error_code stack::push(const double x)const//入栈
{
if(full())return overflow;
data[count]=x;
count ++;
return success;
}
error_code stack::pop()//删除栈顶元素
{
if(empty())
return underflow;
count--;
return success;
}
void hahaha(int n)
{
stack S;
double mod,x;
while(n!=0)
{
mod=n%8;
S.push (mod);
n=n/8;
}
while (!S.empty())
{
S.get_top(x);
S.pop();
cout<<x<<endl;
}
}
void main()
{
double a=100;
hahaha(a);
}
using namespace std;
class stack
{
public:
stack();
bool empty() const;
bool full() const;
enum error_code{overflow,underflow,success};
error_code get_top(double &)const;
error_code push(const double);
error_code pop();
private:
int count;
double date[10000];
};
stack::stack()//初始化
{
count=0;
};
bool stack::empty()const//判空
{
if(count==0)
return 1;
return 0;
}
bool stack::full()const//判满
{
if(count==10000)
return 1;
return 0;
}
error_code stack::get_top(double &x)//出栈
{
if(empty())return underflow;
else
{
x=data[count-1];
return success;
}
}
error_code stack::push(const double x)const//入栈
{
if(full())return overflow;
data[count]=x;
count ++;
return success;
}
error_code stack::pop()//删除栈顶元素
{
if(empty())
return underflow;
count--;
return success;
}
void hahaha(int n)
{
stack S;
double mod,x;
while(n!=0)
{
mod=n%8;
S.push (mod);
n=n/8;
}
while (!S.empty())
{
S.get_top(x);
S.pop();
cout<<x<<endl;
}
}
void main()
{
double a=100;
hahaha(a);
}