資源簡介
一個數據結構的c++程序,關于數字進制的轉換,不過還是比較簡單
代碼片段和文件信息
#include
using?namespace?std;
typedef?int?ElemType;
#define?MAXSIZE?100
#define?FALSE?0
#define?TRUE?1
typedef?struct
{ElemType?data[MAXSIZE];
?int?top;
}SeqStack;
/*-------------順序棧的初始化----------*/
SeqStack?SeqStackInit(SeqStack?S)
{
?S.top=-1;
?return?S;
}
/*-------------判棧空------------------*/
int?SeqStackEmpty(SeqStack?S)
{
?if?(S.top==-1)?return?TRUE;
?else?return?FALSE;
}
/*-------------入棧--------------------*/
SeqStack?SeqStackPush(SeqStack?S?ElemType?X)
{
?if(S.top==MAXSIZE-1)
?{cout<<“棧滿“< ??exit(0);
?}//棧滿,退出運行
?S.top++;
?S.data[S.top]=X;
?return?S;
}
/*-------------出棧--------------------*/
ElemType?SeqStackPop(SeqStack?S)
{ElemType?X;
?if(S.top==-1)
?{cout<<“棧空“< ?X=S.data[S.top];
?S.top--;
?return
- 上一篇:C語言課程設計——個人物品管理
- 下一篇:咖啡店管理系統
評論
共有 條評論