头文件:
const int StackSize=100;
template<class DataType>
class SeqStack
{
public:
SeqStack(){top=-1;}
~SeqStack(){}
void Push(DataType x);
DataType Pop();
int Length();
DataType GetTop(){if(top!=-1)return data[top];}
int Empty(){if (top==-1) return 1; else return 0;}
private:
DataType data[StackSize];
int top;
};
template<class DataType>
void SeqStack<DataType>::Push(DataType x)
{
if(top==StackSize-1)throw"上溢";
data[++top]=x;
}
template<class DataType>
DataType SeqStack<DataType>::Pop()
{DataType x;
if(top==-1)throw"下溢";
x=data[top--];
return x;
}
template<class DataType>
int SeqStack<DataType>::Length()
{
return top+1;
}
一、八进制转二进制
#include <iostream>
#include <math.h>
#include "Seq