Download presentation
Presentation is loading. Please wait.
1
Time to finish first stack program
Computer Science 2 4/18/2014 Dry Run Time to finish first stack program Second Stack Program
2
procedure c(var top:ptrtype); var temp:ptrtype; begin temp:=top;
program DryRunPointers; type ptrtype = ^rectype; rectype = record score:integer; next:ptrtype; end; var top:ptrtype; count:integer; procedure a(var top:ptrtype;count:integer); temp:ptrtype; begin new(temp); temp^.score:=count; temp^.next:=top; top:=temp; procedure b(top:ptrtype); temp:=top; if top<> nil then repeat writeln(temp^.score); temp:=temp^.next; until (temp=nil) or (temp=top); procedure c(var top:ptrtype); var temp:ptrtype; begin temp:=top; top:=top^.next; dispose(temp); end; procedure d(var top:ptrtype); while temp^.next<> nil do temp:=temp^.next; temp^.next:=top; begin {Of the main body}; top:=nil; for count:= 1 to 4 do a(top,2*count); b(top); c(top); d(top); end.
3
Online Time to Finish First Stack Program
4
A VALuable Procedure val(String, RealOrIntegerVariable, IntegerErrorCode); Converts a String into a real or an integer value program test; var error:integer; x:real; number:string; begin writeln('Please enter a number (-1 to quit)'); readln(number); while (number <> '-1') do val(number, x, error); if error = 0 then writeln(x) else writeln('Error !!!'); end; end.
5
Second Stack Program Hire ‘em, Fire ‘em
Write a program to model a human resource department with the following Menu: Hire an employee (Name, Job title, Phone Number) Fire an employee, based solely on seniority Show all employees Push: Save employees to a file Push: Load employees from a file back into the stack.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.