⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 很好的源程序,可以为大家的学习提供方便学习.
💻 CPP
字号:
//                              <栈演示程序>
//                              作者:林华锋
//                              版权:LC工作室
//                              日期:2000.05
//                              修改:2000.05
//
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
const int max=10;
int cp=0;int buf[max];
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
ProgressBar1->Max=max;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::push(int temp)
{
if(!Full())
{
buf[cp]=temp;
cp++;
}
}
//---------------------------------------------------------------------------
int __fastcall TForm1::pop(void)
{
return Empty()?NULL:buf[--cp];
}
//---------------------------------------------------------------------------
bool __fastcall TForm1::Full(void)
{
bool flag=false;
if(cp==max)
{
Beep();
ShowMessage("栈已经满!");
flag=true;
}
return flag;
}
//---------------------------------------------------------------------------
bool __fastcall TForm1::Empty(void)
{
bool flag=false;
if(cp==0)
{
Beep();
ShowMessage("栈已经空!");
flag=true;
}
return flag;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int lc;
if(!Edit1->Text.IsEmpty())
{
lc=Edit1->Text.ToInt();
push(lc);
Edit1->Clear();
}
else
{
Beep();
ShowMessage("请输入一个整形数字!");
}
ProgressBar1->Position=cp;
Edit1->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
if(!Empty())
Edit2->Text=pop();
ProgressBar1->Position=cp;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -