Solved

stack input & output

Posted on 2000-03-28
2
262 Views
Last Modified: 2010-04-16
I want A program As Aunit To Input In Stack And Output Of it And And I want This Code To Help At Some Algorithms
0
Comment
Question by:hassan_ahmed
2 Comments
 

Accepted Solution

by:
amgedeldirdiri earned 75 total points
ID: 2664553
{You Can Use This Code To Do What Do You Want By Stack And This is Simple Code To Show How You Can Made Stack }
Unit Stack;
Interface
Uses Crt;
Const
Max=50;
Buttomstack=0;
Type
   TStack=Record
    Item:Array[1..Max]Of Char;
    Top:Buttomstack..Max;
   End;
   RStack=Record
    Item:Array[1..Max]Of Real;
    Top:Buttomstack..Max;
    End;
Procedure MakStackEmpty(Var S:TStack);
Function Empty(S:TStack):Boolean;
Function Full(S:TStack):Boolean;
Function Pop(Var S:TStack):Char;
Procedure Push(Var S:TStack; X:Char);
Procedure MakRStackEmpty(Var S:RStack);
Function REmpty(S:RStack):Boolean;
Function RFull(S:RStack):Boolean;
Function RPop(Var S:RStack):Real;
Procedure RPush(Var S:RStack; X:Real);
Implementation
Procedure MakStackEmpty(Var S:TStack);
Begin
   S.Top:=ButtomStack;
end;
Function Empty(S:TStack):Boolean;
Begin
  Empty:=S.Top=ButtomStack;
End;

Function Full(S:TStack):Boolean;
Begin
  Full:=S.Top=Max;
End;
Function Pop(Var S:TStack):Char;
Begin
   If Empty(S) Then
     Writeln('Stack Is Under Flow')
   Else
   Begin
     Pop:=S.Item[S.Top];
     S.Top:=S.Top-1;
   End;
End;
Procedure Push(Var S:TStack; X:Char);
Begin
   If Full(S) Then
    Writeln('Stack Is Overflow')
   Else
   Begin
     S.Top:=S.Top+1;
     S.Item[S.Top]:=X;
   End;
End;
Procedure MakRStackEmpty(Var S:RStack);
Begin
   S.Top:=ButtomStack;
end;
Function REmpty(S:RStack):Boolean;
Begin
  REmpty:=S.Top=ButtomStack;
End;
Function RFull(S:RStack):Boolean;
Begin
  RFull:=S.Top=Max;
End;
Function RPop(Var S:RStack):Real;
Begin
   If REmpty(S) Then
     Writeln('Stack Is Under Flow')
   Else
   Begin
     RPop:=S.Item[S.Top];
     S.Top:=S.Top-1;
   End;
End;
Procedure RPush(Var S:RStack; X:Real);
Begin
   If RFull(S) Then
    Writeln('Stack Is Overflow')
   Else
   Begin
     S.Top:=S.Top+1;
     S.Item[S.Top]:=X;
   End;
End;
End.

0
 

Author Comment

by:hassan_ahmed
ID: 2664584
thank you for your code and i will get it to do my work that i have
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now