Solved

stack input & output

Posted on 2000-03-28
2
270 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Ransomware continues to grow in reach and sophistication, putting data everywhere at risk. Learn how to avoid being caught in its sinister clutches with these 11 key tips.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

807 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